aws / aws/aws-cdk

custom_resources: Can't utilize the data received from api call

Open
#25,737 2 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/custom-resources feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

I am trying to use the custom resource to perform an AWS CLI call.
Service: Route53Resolver
Action: listFirewallDomainLists

The problem is with the Custom Resource construct itself. What I would want to do is put that data into a variable and then map out the key/value pairs. Since I know what the api call will return, it should be simple enough for me to use a mapping function to find the KEY I want and use that.

However, this is not possible at all. I even created a case with AWS Support (12784295111) and they couldn't figure it out either. They suggested I create an issue here.

### Expected Behavior

1. Assign the returned data to a variable.
2. Access that data with the very least being able to pull out specific Key/Value pairs.

What would be optimal is if these api calls were actually mapped and when I go to access the variable that holds the returned value, I can use a method to access the keys. Anything that is "AWS Managed" should be mapped by default with calls that would return values created by a users as something that needs to be explicit. In this case, it would be a domain list that I name myself which means I'd have to spell out the name in a string 'my_domain_list'.

### Current Behavior

The error I get in the Cloudformation template is:
CustomResource attribute error: Vendor response doesn't contain Data key in object

I get some derivative of that if I use '*', '', or anything else. I can't even name a key to get a returned value when using the method of ".getResponseField". I don't see ANY way of accessing the data at all.

### Reproduction Steps

The code I use:

```
const awsManagedDomainsProvider = new AwsCustomResource(this, 'AwsManagedDomainsProvider', {
onUpdate: {
service: 'Route53Resolver',
action: 'listFirewallDomainLists',
parameters: {},
physicalResourceId: PhysicalResourceId.of('AwsManagedDomainsProvider'),
},
policy: AwsCustomResourcePolicy.fromSdkCalls({ resources: AwsCustomResourcePolicy.ANY_RESOURCE }),
});
```

### Possible Solution

At the very least, allow me to work with the "data" that gets returned. I'm fine if its just ALL the data and then I have to sift through it by naming the specific "key" that I want.

### Additional Information/Context

_No response_

### CDK CLI Version

2.78.0 (build 8e95c37)

### Framework Version

_No response_

### Node.js Version

v18.16.0

### OS

Ubuntu

### Language

Typescript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the AwsCustomResource construct and its getResponseField behavior, then reproduce the Route53Resolver listFirewallDomainLists call from the issue. Determine how the custom resource handles SDK responses without a Data key; done means the returned response can be assigned and queried for specific values without the reported CloudFormation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.