- Newest
- Most votes
- Most comments
It appears there is an issue with how the build_secrets parameter is being processed in your CDK code. The error you're seeing occurs because the Docker BuildKit expects secrets to be passed in a specific format.
When using build_secrets with DockerImageCode.from_image_asset() or similar methods, the CDK should indeed store the secret value in a temporary file and then reference that file in the Docker build command. The correct format for the --secret flag should be --secret id=github_token,src=/path/to/temporary/file as you mentioned.
The command being generated (--secret id=github_token,testtoken123) is incorrect - it's trying to use the actual token value directly in the command line rather than storing it in a file and referencing the file path.
This appears to be a bug in how the CDK is handling build secrets in version 2.200. You might want to:
- Try updating to the latest CDK version to see if this has been fixed
- As a workaround, you could create a temporary file with your secret and use the
build_argsparameter instead, with a reference to that file - File an issue in the AWS CDK GitHub repository to report this bug
Remember that Docker BuildKit must be enabled to use build secrets, which you've confirmed is the case in your environment.
Sources
RepositoryImage — AWS Cloud Development Kit 2.201.0 documentation
DockerImage — AWS Cloud Development Kit 2.201.0 documentation
TagParameterContainerImage — AWS Cloud Development Kit 2.201.0 documentation
DockerImageFunction — AWS Cloud Development Kit 2.201.0 documentation
Relevant content
- asked 3 years ago
- AWS OFFICIALUpdated 2 years ago
