question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(cdk-assets): ecs.RepositoryImage.fromTarball not working in cdk pipelines

See original GitHub issue

What 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:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

1reaction
derrikecommented, Jan 5, 2022

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:

"executable": [
  "sh",
  "-c",
  "docker load -i ../asset.<random_id>.tar | sed \"s/Loaded image: //g\""
]

^ 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.

0reactions
github-actions[bot]commented, Nov 25, 2022

⚠️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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

class ContainerImage · AWS CDK
Reference an image on DockerHub or another online registry. static fromTarball(tarballFile), Use an existing tarball for this container image. bind(scope, ...
Read more >
Assets execution step failing in codepipeline - CDK (Java)
I'm trying to deploy a module using the pipeline and for some reason its stuck at the 'Assets' execution step. Error: Cannot read...
Read more >
Using AWS CDK, GitLab, Fargate and CloudFront for Django ...
4 - CDK Assets (ECR and S3 buckets that CDK uses internally to manage ... Having worked with CloudFormation for almost a year,...
Read more >
aws-cdk.assets-docker 0.32.0 - PyPI
Images are built from a local Docker context directory (with a Dockerfile ), uploaded to ECR by the CDK toolkit and/or your app's...
Read more >
Integrating AWS CDK Pipelines and sam local testing
This allows you to make changes to your pipeline even after the initial deployment. The Assets stage uploads all cdk assets to their...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found