Skip to content

cli: cdk bootstrap using temporary credentials (session) fails to create resources in CloudFormation stack #35134

@nick96

Description

@nick96

Describe the bug

The CloudFormation stack created via cdk bootstrap fails to create any resources when run using temporary credentials via was-vault. It fails with the error:

The security token included in the request is invalid

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Library Version

No response

Expected Behavior

Bootstrap successfully runs using the temporary credentials.

Current Behavior

Bootstrap creates the CloudFormation stack but fails to create the resources. It then fails to rollback due to the same permissions error.

Reproduction Steps

  1. Init a new project with cdk init app --language typescript
  2. Update stack to set the right account ID and region
  3. Run was-vault exec <profile> -- npx cdk bootstrap

Possible Solution

No response

Additional Information/Context

I was trying to bootstrap my account using the cdk bootstrap command using aws-vault for authentication. This creates a session which is passed through to the subprocess via the environment variables:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_SESSION_TOKEN

When I ran the bootstrap just using my long lived access key (via the --no-session flag on was-vault), the CloudFormation stack was able to successfully create all the resources.

AWS CDK Library version (aws-cdk-lib)

2.206.0

AWS CDK CLI version

2.1023.0 (build 45ceb89)

Node.js Version

v24.4.1

OS

MacOS

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.cause/not-a-bugNot a bug (might still be a documentation issue, might still need work)p3package/toolsRelated to AWS CDK Tools or CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions