aws / aws/aws-cdk

(custom-resources): cannot find response data key

Open
#27,626 5 comments 1 reaction 0 assignees View on GitHub
@aws-cdk/custom-resources bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

### Describe the bug

I'm using custom-resources provider with a CustomResource.
Trying to use `theCustomResource.getAtt('roleArns.iamDbAuthRoleArn')` in aws-cdk fails.

I've verified the provider framework does upload the correct Data to S3, but still I'm unable to retrieve it and I'm at a loss of what I can do...

```
2023-10-20T15:13:01.747Z 4db3e534-b9ac-4911-bfb1-7433ab6d82b9 INFO [provider-framework] submit response to cloudformation
{
"Status": "SUCCESS",
"Reason": "SUCCESS",
"StackId": "",
"RequestId": "",
"PhysicalResourceId": "",
"LogicalResourceId": "RdsIamAuthCreator",
"Data": {
"roleArns": {
"iamDbAuthRoleArn": "",
"retoolReadUserArn": ""
}
}
}
```

### Expected Behavior

getAtt call to succeed as the key is obviously present in the Data that was put in S3.

### Current Behavior

Fails with error `CustomResource attribute error: Vendor response doesn't contain roleArns.iamDbAuthRoleArn `

### Reproduction Steps

Handler:
```
async (event, context) => {
logger.info('Processing request', {
event,
});

let result: CloudFormationCustomResourceEventResult | undefined = undefined;

switch (event.RequestType) {
case 'Create':
result = await createFn(event);
break;
case 'Update':
if (updateFn) {
result = await updateFn(event);
}
break;
case 'Delete':
if (deleteFn) {
result = await deleteFn(event);
}
break;
default:
logger.error(`Unknown request type: ${event['RequestType']}`);
throw Error(`Unknown request type: ${event['RequestType']}`);
}
if (result) {
return result;
}
};
```

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.69.0 (build 60a5b2a)

### Framework Version

_No response_

### Node.js Version

v18.12.1

### OS

Macos

### Language

TypeScript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at the custom-resources provider framework handler and the CloudFormation response retrieval path, using the supplied handler and getAtt('roleArns.iamDbAuthRoleArn') reproduction. Compare the nested Data object uploaded to S3 with the key lookup that reports the missing attribute; done means the nested attribute resolves successfully in the reproduction without breaking existing response handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, node.js, typescript
Domain
backend, cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.