aws / aws/aws-cdk

CustomResources: Clarify limitation about returning an array from a custom resource in docs

Open
#23,601 12 comments 0 reactions 1 assignee Claimed by @peterwoodworth View on GitHub
@aws-cdk/custom-resources documentation effort/small feature-request p1
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

When I deploy my stack with an AWS Custom Resource for the DescribeVpcEndpointServices API with the parameter "ServiceNames", I receive the following:

Stack Deployments Failed: Error: The stack named <> failed to deploy: UPDATE_ROLLBACK_COMPLETE: CustomResource attribute error: Vendor response doesn't contain ServiceDetails key

### Expected Behavior

I should have been able to get the service details of the vpc endpoint from this AWS custom resource. I was able to have another EC2 API (describeNetworkInterfaces) work with the same format, just replaced the action with describeNetworkInterfaces and the parameter name. The VPC endpoint I used is definitely valid, I was able to call the API through the AWS CLI and a manual lambda I made.

### Current Behavior

6:17:25 PM | CREATE_FAILED | AWS::EC2::Subnet | ...Subnet08F0B33B
CustomResource attribute error: Vendor response doesn't contain ServiceDetails key in object arn:aws:cloudformation:us-east-1:734789510895:stack/beta/05874f40-8de
e-11ed-b85a-12795384352b|DescribeVpcEndpointServicesA596F9B2|82de965e-bf1b-4217-95bd-58f45b6f6206 in S3 bucket cloudformation-custom-resource-storage-useast1

### Reproduction Steps

```
const describeVpcEndpointServices = new custom_resources.AwsCustomResource(
this,
"DescribeVpcEndpointServices",
{
onCreate: {
service: "EC2",
action: "describeVpcEndpointServices",
parameters: {
ServiceNames: [com.amazonaws.us-east-1.voiceid],
},
physicalResourceId: custom_resources.PhysicalResourceId.of(Date.now().toString()),
},
onUpdate: {
service: "EC2",
action: "describeVpcEndpointServices",
parameters: {
ServiceNames: [com.amazonaws.us-east-1.voiceid],
},
physicalResourceId: custom_resources.PhysicalResourceId.of(Date.now().toString()),
},
policy: {
statements: [
new iam.PolicyStatement({
actions: ["*"],
resources: ["*"],
}),
],
},
functionName: "DescribeVpcEndpointServices"
}
);

const responseString = describeVpcEndpointServices.getResponseField("ServiceDetails");
```

The last line returns an error.

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

no cdk version found, output that it was using latest version

### Framework Version

_No response_

### Node.js Version

v14.21.2

### OS

Linux

### Language

Typescript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.