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-lib/aws-ssm: StringListParameter (Error in FnJoin) #27810

Open
anneadb opened this issue Nov 2, 2023 · 8 comments
Open

aws-cdk-lib/aws-ssm: StringListParameter (Error in FnJoin) #27810

anneadb opened this issue Nov 2, 2023 · 8 comments
Labels
@aws-cdk/aws-ssm Related to AWS Systems Manager bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@anneadb
Copy link

anneadb commented Nov 2, 2023

Describe the bug

I added a StringListParameter to my existing Stack and suddenly get the following error:

Error: FnJoin requires at least one value to be provided
    at Function.join (/Users/path_to_my_git_repo/node_modules/aws-cdk-lib/core/lib/cfn-fn.js:1:1026)
    at new StringListParameter (/Users/path_to_my_git_repo/node_modules/aws-cdk-lib/aws-ssm/lib/parameter.js:1:13016)
    at EosAwsAccountMlBootstrapStack.setupVpc (/Users/path_to_my_git_repo/lib/eos-aws-account-ml-bootstrap-stack.ts:157:5)
    at new EosAwsAccountMlBootstrapStack (/Users/path_to_my_git_repo/lib/eos-aws-account-ml-bootstrap-stack.ts:42:10)
    at Object.<anonymous> (/Users/path_to_my_git_repo/bin/eos-aws-account-ml-bootstrap.ts:29:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module.m._compile (/Users/path_to_my_git_repo/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/path_to_my_git_repo/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1119:32)

Here is the code I added:

const vpc = ec2.Vpc.fromLookup(this, "Vpc", {
      vpcName: vpcName,
      subnetGroupNameTag: "type",
    })

const appSubnetGroupSelections = vpc.selectSubnets({
      subnetGroupName: "app",
    })

new cdk.aws_ssm.StringListParameter(this, "VpcParamSubnets", {
      parameterName: "/iac/vpc/appSubnetIds",
      stringListValue: appSubnetGroupSelections.subnetIds,
    })

Expected Behavior

Successfully synth and deploy stack.

Current Behavior

Cannot synth or deploy stack.

Reproduction Steps

For some reason this error only occurs in some AWS accounts but not in others so it may be hard to reproduce. We roll out this stack in 8 different accounts and I currently cannot tell why it fails in one account but not the others.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.103.1

Framework Version

No response

Node.js Version

v18.17.0

OS

MacOS Sonoma 14.1

Language

TypeScript

Language Version

No response

Other information

No response

@anneadb anneadb added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 2, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ssm Related to AWS Systems Manager label Nov 2, 2023
@anneadb
Copy link
Author

anneadb commented Nov 2, 2023

I think #21682 may be related

@pahud
Copy link
Contributor

pahud commented Nov 10, 2023

I can't reproduce this.

Are you able to print it in the CfnOutput like this?

new CfnOutput(this, 'SelectedSubnetIds', { value: appSubnetGroupSelections.subnetIds.join(',') })

And see the result like this?

Outputs:
demo.SelectedSubnetIds = subnet-071c85610846aa9c0,subnet-0ef7ac49e1edb06e4,subnet-0e2177a10a166f87d

@pahud pahud added p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Nov 10, 2023
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Nov 12, 2023
@anneadb
Copy link
Author

anneadb commented Nov 13, 2023

Hi @pahud ,

yes, if I remove the StringListParameter and instead add the CfnOutput I can successfully run cdk diff and cdk synth:

new cdk.CfnOutput(this, "SelectedSubnetIds", {
      value: appSubnetGroupSelections.subnetIds.join(","),
    })

    // new cdk.aws_ssm.StringListParameter(this, "VpcParamSubnets", {
    //   parameterName: "/iac/vpc/appSubnetIds",
    //   stringListValue: appSubnetGroupSelections.subnetIds,
    // })

From the synth I see:

Outputs:
  SelectedSubnetIds:
    Value: subnet-12345someid,subnet-12345someid,subnet-12345someid

@anneadb
Copy link
Author

anneadb commented Nov 13, 2023

Now this is really strange: If I add both the CfnOutput and StringListParameter then I can also synth the stack successfully. I have no idea why?

@anneadb
Copy link
Author

anneadb commented Nov 13, 2023

But in another project I get the same error message in a completely different setup:
I have three stacks in my app, stacks 1 and 2 are only deployed to one account but stack 3 is also deployed to other accounts. Stack 1 contains a StringListParameter. Whenever I try to deploy stack 3 in another account from stack 1 I get the same error message from above.
If I uncomment stack 1 and 2 from the app then I can deploy stack 3 successfully.
Could this be another hint for the source of the issue?

@anneadb
Copy link
Author

anneadb commented Nov 13, 2023

I found this comment https://stackoverflow.com/a/73249828/10829644 indicating that sometime the cdk.context.json could cause issues with deployment. Could that be something?
I tried removing this file but then none of my existing stacks sync anymore.

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Nov 13, 2023
@anneadb
Copy link
Author

anneadb commented Dec 4, 2023

Hi @pahud ,

any ideas for what else I can test?
I am still seeing this issue and therefore cannot store any string lists - which would be really useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ssm Related to AWS Systems Manager 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

2 participants