Skip to content

(core): Templating error on custom-resource introduced with version 1.92 #13465

@mzakarian

Description

@mzakarian
for (let index = 0; index < existingVpc.availabilityZones.length; index++) {
      let getEndpointIp = new AwsCustomResource(this, idPrefix + 'GetEndpointIp' + index, {
        policy: AwsCustomResourcePolicy.fromSdkCalls({resources: AwsCustomResourcePolicy.ANY_RESOURCE}),
        onUpdate: {
          action: 'describeNetworkInterfaces',
          service: 'EC2',
          parameters: {NetworkInterfaceIds: vpcendpoint.vpcEndpointNetworkInterfaceIds},
          physicalResourceId: PhysicalResourceId.of('DirectoryId'),
          outputPath: 'NetworkInterfaces.' + index + '.PrivateIpAddress'
        }
      })
      targetGroup.addTarget(new IpTarget(Token.asString(getEndpointIp.getResponseField('NetworkInterfaces.' + index + '.PrivateIpAddress'))));
    }

We are doing this, because we need to put an api gateway behind a load balancer (company policy). If there is a better solution to do this, feedback is welcome.

Reproduction Steps

this is the output with aws-cdk/core 1.91

...
  announceGetEndpointIp0D5B4E67A:
    Type: Custom::AWS
    Properties:
      ServiceToken:
        Fn::GetAtt:
          - AWS12345678
          - Arn
      Create:
        action: describeNetworkInterfaces
        service: EC2
        parameters:
          NetworkInterfaceIds:
            Fn::GetAtt:
              - announcevpcannouncevpcendpoint55991BB5
              - NetworkInterfaceIds
        physicalResourceId:
          id: DirectoryId
        outputPath: NetworkInterfaces.0.PrivateIpAddress
      Update:
        action: describeNetworkInterfaces
        service: EC2
        parameters:
          NetworkInterfaceIds:
            Fn::GetAtt:
              - announcevpcannouncevpcendpoint55991BB5
              - NetworkInterfaceIds
        physicalResourceId:
          id: DirectoryId
        outputPath: NetworkInterfaces.0.PrivateIpAddress
      InstallLatestAwsSdk: true
    DependsOn:
      - announceGetEndpointIp0CustomResourcePolicyC5EFFE47
    UpdateReplacePolicy: Delete
    DeletionPolicy: Delete
    Metadata:
      aws:cdk:path: announce-dev-local/announce-GetEndpointIp0/Resource/Default
...

this is the output with aws-cdk/core 1.92

...
  announceGetEndpointIp0D5B4E67A:
    Type: Custom::AWS
    Properties:
      ServiceToken:
        Fn::GetAtt:
          - AWS12345678
          - Arn
      Create:
        Fn::Join:
          - ""
          - - '{"action":"describeNetworkInterfaces","service":"EC2","parameters":{"NetworkInterfaceIds":"'
            - Fn::GetAtt:
                - announcevpcannouncevpcendpoint55991BB5
                - NetworkInterfaceIds
            - '"},"physicalResourceId":{"id":"DirectoryId"},"outputPath":"NetworkInterfaces.0.PrivateIpAddress"}'
      Update:
        Fn::Join:
          - ""
          - - '{"action":"describeNetworkInterfaces","service":"EC2","parameters":{"NetworkInterfaceIds":"'
            - Fn::GetAtt:
                - announcevpcannouncevpcendpoint55991BB5
                - NetworkInterfaceIds
            - '"},"physicalResourceId":{"id":"DirectoryId"},"outputPath":"NetworkInterfaces.0.PrivateIpAddress"}'
      InstallLatestAwsSdk: true
    DependsOn:
      - announceGetEndpointIp0CustomResourcePolicyC5EFFE47
    UpdateReplacePolicy: Delete
    DeletionPolicy: Delete
    Metadata:
      aws:cdk:path: announce-dev-local/announce-GetEndpointIp0/Resource/Default
...

What did you expect to happen?

After using cdk deploy we expected the same behavior as in version 1.91 with successful deployment.

What actually happened?

The error only occurs during a cdk deploy with version 1.92.

26/44 | 8:32:42 AM | CREATE_FAILED        | Custom::AWS                               | announce-GetEndpointIp2/Resource/Default (announceGetEndpointIp20B447BE7) Template error: every Fn::Join object requires two parameters, (1) a string delimiter and (2) a list of strings to be joined or a function that returns a list of strings (such as Fn::GetAZs) to be joined.
	new CustomResource (/builds/marceldarvis/toolbox/services/announce-pipeline-modules-service/node_modules/@aws-cdk/core/lib/custom-resource.ts:119:21)
	\_ new AwsCustomResource (/builds/marceldarvis/toolbox/services/announce-pipeline-modules-service/node_modules/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts:374:27)

Environment

  • CDK CLI Version :1.92
  • Framework Version:None
  • Node.js Version:v14.16.0
  • OS :linux
  • Language (Version):TypeScript (4.2.3)

Other

We assume that this issue is related to this change:


This is 🐛 Bug Report

Metadata

Metadata

Assignees

Labels

@aws-cdk/coreRelated to core CDK functionalitybugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions