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

aws-cdk: CdkJsonStringify and AWSCDKCfnUtilsProviderCustomResourceProvider are not available in node children #28215

Closed
marcininfra opened this issue Dec 1, 2023 · 5 comments
Labels
@aws-cdk/custom-resources Related to AWS CDK Custom Resources bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@marcininfra
Copy link

marcininfra commented Dec 1, 2023

Describe the bug

I've educated myself that CDK supports passing only simple types, when I execute the code below a new custom resource is created just for handling an array returned by vpc_endpoint.vpc_endpoint_network_interface_ids.

This is the code that I use.

        vpc_endpoint = vpc.add_interface_endpoint(
            'api-gateway-vpce', service=ec2.InterfaceVpcEndpointAwsService.APIGATEWAY
        )

        custom_resources.AwsCustomResource(
            self, 'endpoint-ips',
            on_update=custom_resources.AwsSdkCall(
                action='describeNetworkInterfaces',
                service='EC2',
                parameters={
                    'NetworkInterfaceIds':vpc_endpoint.vpc_endpoint_network_interface_ids
                },
                physical_resource_id=custom_resources.PhysicalResourceId.of(get_resource_prefix('endpoint-nics')),
            ),
            policy=custom_resources.AwsCustomResourcePolicy.from_sdk_calls(
                resources=custom_resources.AwsCustomResourcePolicy.ANY_RESOURCE
            )
        )

This is an additional custom resource that is produced by cdk and doesn't exist in the children structure:

    "AWSCDKCfnUtilsProviderCustomResourceProviderHandlerCF82AA57": {
      "Type": "AWS::Lambda::Function",
      "Properties": {
        "Code": {
          "S3Bucket": "***",
          "S3Key": "***"
        },
        "Timeout": 900,
        "MemorySize": 128,
        "Handler": "__entrypoint__.handler",
        "Role": {
          "Fn::GetAtt": [
            "AWSCDKCfnUtilsProviderCustomResourceProviderRoleFE0EE867",
            "Arn"
          ]
        },
        "Runtime": "nodejs18.x"
      },
      "DependsOn": [
        "AWSCDKCfnUtilsProviderCustomResourceProviderRoleFE0EE867"
      ],
      "Metadata": {
        "aws:cdk:path": "***",
        "aws:asset:path": "***",
        "aws:asset:property": "Code"
      }
    },
    "CdkJsonStringify2": {
      "Type": "Custom::AWSCDKCfnJsonStringify",
      "Properties": {
        "ServiceToken": {
          "Fn::GetAtt": [
            "AWSCDKCfnUtilsProviderCustomResourceProviderHandlerCF82AA57",
            "Arn"
          ]
        },
        "Value": {
          "Fn::GetAtt": [
            "essvpcessapigatewayvpce16FC46B0",
            "NetworkInterfaceIds"
          ]
        }
      },
      "UpdateReplacePolicy": "Delete",
      "DeletionPolicy": "Delete",
      "Metadata": {
        "aws:cdk:path": "***"
      }
    }
  }

Expected Behavior

I expected Custom::AWSCDKCfnJsonStringify to be found in the node structure.

Current Behavior

The problem I have is Custom::AWSCDKCfnJsonStringify cannot be found in node children. It looks like it is added when python execution ends. What I want to do is to add a condition to Custom::AWSCDKCfnJsonStringify as I create essvpcessapigatewayvpce16FC46B0 conditionally based on input parameters. As follows:

vpc_endpoint.node.default_child.cfn_options.condition = my_condition

How can I access Custom::AWSCDKCfnJsonStringify in python to add my modifications?

Reproduction Steps

''

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.111.0

Framework Version

No response

Node.js Version

v18.18.2

OS

Mac OS

Language

Python

Language Version

No response

Other information

No response

@marcininfra marcininfra added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 1, 2023
@github-actions github-actions bot added the @aws-cdk/custom-resources Related to AWS CDK Custom Resources label Dec 1, 2023
@pahud
Copy link
Contributor

pahud commented Dec 5, 2023

Why do you need to access the Custom::AWSCDKCfnJsonStringify custom resource? Can you explain more about that?

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Dec 5, 2023
@marcininfra
Copy link
Author

marcininfra commented Dec 5, 2023

I create a vpc endpoint only when the installation_type input parameter is private. Otherwise, when public installation type is chosen is fails as it cannot find essvpcessapigatewayvpce16FC46B0. I need to add there a cloudformation condition that creates that custom resource only when the input parameter is private.

@FarrOut
Copy link

FarrOut commented Apr 1, 2024

one use-case is being able to define a custom name for the handler's role i.e. AWSCDKCfnUtilsProviderCustomResourceProviderRoleFE0EE867

Update:
got around this particular use-case with iam.Role.customize_roles

@pahud
Copy link
Contributor

pahud commented Jun 3, 2024

Closing this issue now. Feel free to reopen if it's still relevant.

@pahud pahud closed this as completed Jun 3, 2024
Copy link

github-actions bot commented Jun 3, 2024

⚠️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/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

3 participants