cli: `cdk bootstrap` using temporary credentials (session) fails to create resources in CloudFormation stack
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### 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 -- 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](https://github.com/99designs/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_
Contributor guide
Research direction
Start by reproducing `cdk bootstrap` from the reported TypeScript project with `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN`, then compare it with the `--no-session` case. Trace the `cdk bootstrap` entry point through CloudFormation resource creation and rollback; done means temporary credentials allow all resources to be created and the stack to roll back successfully on failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cli, cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100