(cdk-assets): ecs.RepositoryImage.fromTarball not working in cdk pipelines
See original GitHub issueWhat is the problem?
Hi, when trying to create ecs cluster with ecs.RepositoryImage.fromTarball the Asset build step in my pipeline fails with the error:
Error parsing reference: "" is not a valid repository/tag: invalid reference format
The command generated to load the docker image in the Asset build step is not properly quoted. Log output of the Asset build step.
Building Docker image using command 'sh,-c,docker load -i asset.<random numbers>.tar | sed "s/Loaded image: //g"'
This turns into something like below and that won’t work, as sh -c is not taking the additional arguments passed on the command line into account. If you run the command below you get the help output show of docker, instead of docker loading the image.
sh -c docker load -i asset.<random numbers>.tar | sed "s/Loaded image: //g
The command should be properly quoted for this to work like below:
sh -c 'docker load -i asset.<random numbers>.tar | sed "s/Loaded image: //g"'
Reproduction Steps
Create a pipeline with aws-cdk-lib/pipelines, add a stage with an ECR stack that contains the ecs.RepositoryImage.fromTarball, and provide it with a local docker image.
What did you expect to happen?
Ecs cluster being created
What actually happened?
Pipeline execution stopped.
CDK CLI Version
2.1.0 (build f4f18b1)
Framework Version
No response
Node.js Version
v16.3.0
OS
Ubuntu
Language
Typescript
Language Version
No response
Other information
I tried patching the tarball-asset.js
to include additional quotes, and tried every possible quote combination I could think of but none of them worked. Then I found out that shell.js is doing escaping of characters x = x.replace("'", "'\"'\"'");
so I sort of gave up and created this issue.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:6
Top GitHub Comments
I just had this issue myself and I don’t think the issue is related to the quotes. The problem is the path that it is expected to find the tar. The
cdk-assets
is expecting the tar to be in the assembly CDK Pipeline folder, but that folder just has *.json files. The CDK Pipelines creates additional sub directories, so the assets are actually one level up.I updated the executable line to go up one directory and manually ran
cdk-assets
to publish, which worked:^ docker load -i …/
I would think that this is a problem related to the way CDK Pipelines is generating the asset file for the from_tarball. It needs to be updated to correctly point up one parent directory.
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.