question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cdk.FnJoin synth bug

See original GitHub issue

I’m introducing an output for CloudFormation stack as follow:

new cdk.Output(this, "ApiEndpoint", {
                value: new cdk.FnJoin("", ["https://","dummy.ref",".execute-api.",this.env.region,".amazonaws.com/","stage_name"]),
                description: "Endpoint for this stage of the api"
            })

What I expect from the command

cdk synth

is that a code like the following is created inside the CloudFormation template:

Outputs:
    ApiEndpoint:
        Description: 'Endpoint for this stage of the api'
        Value:
            'Fn::Join':
                - ""
                -
                    - 'https://'
                    - dummy.ref
                    - .execute-api.
                    - eu-central-1
                    - .amazonaws.com/
                    - stage_name
        Export:
            Name: 'PvideoSmartCF:ApiEndpoint'

Instead the generated code is like:

Outputs:
    ApiEndpoint:
        Description: 'Endpoint for this stage of the api'
        Value:
            'Fn::Join':
                - ""
                -
                    -
                        - 'https://'
                        - dummy.ref
                        - .execute-api.
                        - eu-central-1
                        - .amazonaws.com/
                        - stage_name
        Export:
            Name: 'PvideoSmartCF:ApiEndpoint'

Which result in an error during the deployment:

failed: ValidationError: 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. 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.

Do anyone know how to solve this problem, or if it is a a bug or I am doing something wrong?

Thank you fro the support.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
xdodocodexcommented, Aug 6, 2018

Thank you this solved the problem

1reaction
eladbcommented, Aug 6, 2018

FnJoin accepts a variadic argument, so you would want to use it like so:

new cdk.FnJoin("", "https://","dummy.ref",".execute-api.",this.env.region,".amazonaws.com/","stage_name")

Alternatively, you can use the sugar FnConcat:

new cdk.FnConcat("https://","dummy.ref",".execute-api.",this.env.region,".amazonaws.com/","stage_name")
Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting common AWS CDK issues
Exceeding the AWS CloudFormation resource limit is an error during AWS CloudFormation synthesis. The AWS CDK issues a warning if your stack exceeds...
Read more >
awslabs/aws-cdk - Gitter
Hello! I am having an issue when trying to deploy an ElasticSearch domain in an account that already has one. Before you can...
Read more >
Importing VPC IDs into a stack with CDK - DEV Community ‍ ‍
When I wanted to create a CloudFormation template from the CDK code with cdk synth , I received the following error: Error: All...
Read more >
Need help understanding inconsistent behaviour and KMS ...
We do not explicitly create KMS keys. The KMS keys and its policy were auto generated during CDK deploy. To resolve this error,...
Read more >
How to use Parameters in AWS CDK - Complete Guide
After defining the parameters in our CDK stack, if we try to deploy without providing any parameters, we would get an error of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found