Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[custom-resources] getResponseField does not function properly when iterating over lists #9568

Closed
DarkmatterVale opened this issue Aug 10, 2020 · 3 comments
Labels
@aws-cdk/custom-resources Related to AWS CDK Custom Resources bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@DarkmatterVale
Copy link

When using the getResponseField method in a custom resource, it does not properly iterate over lists.

Reproduction Steps

  1. Create a VPC
  2. Add S3 & DynamoDB gateway endpoints in the vpc
  3. Create a security group (name in this example: lambdaSg with setting allowAllOutbound: false)
  4. Use a custom resource to call the AWS API to get the prefix lists, add them as egress targets for the security group:
const prefixListCall = new cr.AwsCustomResource(stack, 'GetPrefixListIds', {
    resourceType: 'Custom::GetPrefixListIds',
    onUpdate: {
        region: "REGION-HERE",
        service: 'EC2',
        action: 'describePrefixLists',
        parameters: {
            MaxResults: 10
        },
        physicalResourceId: cr.PhysicalResourceId.of('GetPrefixListIdsFunction')
    },
    policy: cr.AwsCustomResourcePolicy.fromSdkCalls({
        resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE
    })
});
lambdaSg.connections.allowTo(ec2.Peer.prefixList(prefixListCall.getResponseField('PrefixLists.0.PrefixListId')), ec2.Port.allTraffic());
lambdaSg.connections.allowTo(ec2.Peer.prefixList(prefixListCall.getResponseField('PrefixLists.1.PrefixListId')), ec2.Port.allTraffic());

What did you expect to happen?

When I execute the above CDK and check the outbound rules for the security group in the console, I see 2 rules: one for the 0th item (PrefixLists.0.PrefixListId), and one for the 1st item (PrefixLists.1.PrefixListId).

What actually happened?

When I execute the above CDK and check the outbound rules for the security group in the console, I see only 1 rule for the 0th item (PrefixLists.0.PrefixListId).

Environment

  • CLI Version : 1.39
  • Framework Version: 1.39
  • Node.js Version: 14.0.5
  • OS : Mac OS X
  • Language (Version): TypeScript (3.9.3)

Other

If I replace prefixListCall.getResponseField(...) with hardcoded strings, everything works as expected.


This is 🐛 Bug Report

@DarkmatterVale DarkmatterVale added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 10, 2020
@github-actions github-actions bot added the @aws-cdk/custom-resources Related to AWS CDK Custom Resources label Aug 10, 2020
@jogold
Copy link
Contributor

jogold commented Aug 10, 2020

Can you show the resulting CF template?

@eladb eladb added effort/small Small work item – less than a day of effort p2 labels Aug 17, 2020
@eladb eladb assigned rix0rrr and unassigned eladb Aug 17, 2020
@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Nov 6, 2020
@rix0rrr rix0rrr removed their assignment Jun 3, 2021
@peterwoodworth
Copy link
Contributor

the allowTo method uses addEgressRule under the hood, so i suspect that the cause of this is the issue I've just posted #17201. Please go there to track this issue :)

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/custom-resources Related to AWS CDK Custom Resources bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

No branches or pull requests

6 participants