Error when deploying Docker Image lambda functions using CDK #34740
Unanswered
aandradel19
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I have a CDK project where one of my lambda functions is defined as a DockerImage function, this way:
pinecone_function = lambda_.DockerImageFunction(
scope=self,
id=pinecone_function_name,
function_name=pinecone_function_name,
# Use aws_cdk.aws_lambda.DockerImageCode.from_image_asset to build
# a docker image on deployment
code=lambda_.DockerImageCode.from_image_asset(
# Directory relative to where you execute cdk deploy
# contains a Dockerfile with build instructions
directory=str(pathlib.Path(file).parent.joinpath("pinecone").resolve())
),
timeout = Duration.seconds(900),
memory_size=1024,
environment={
"PINECONE_API_KEY": PINECONE_API_KEY,
"PINECONE_ENV": PINECONE_ENV,
"PINECONE_INDEX": PINECONE_INDEX
}
)
I've always been able to update the code and the deploy the changes using CDK deploy.
But suddendly, the last time I tried to deploy changes for this function now I get this error saying that the tag is immuntable. I had never received this error before, and I never cared about the hash or the tag that the Docker Image had in ECR, it never gave me troubles and I never changed ir or added any parameter related to it. I have tried multiple solutions like indicating an uuid as the hash for the image when I define the function, but it has failed. I've not been able to do any new deployments.
I'm using CDK version 2.88, but also tried more recent versions like 2.149, and the error keeps being the same.
This is the error I'm receiving when doing the deployment (I have redacted some sensitive information). The strange thing is, that image ID does not exist on ECR prior to the deployment, and I see the image in ECR being created with a 0 Byte size.
4a7d6aabd92b: Pushed
5c3f242bd442: Pushed
error from registry: The image tag '897fca3aa741685c3e503d0370639d91f...{redacted}' already exists in the '{redacted}' repository and cannot be overwritten because the tag is immutable.
{redacted}-stack: fail: docker push {redacted AWS account}.dkr.ecr.eu-west-1.amazonaws.com/cdk-hnb...{redacted}-container-assets-{redacted}-eu-west-1:897fca3aa741685c3e503d0370639d91f9566b0db3...{redacted} exited with error code 1: error from registry: The image tag '897fca3aa741685c3e503d0370639d91f956...{redacted}' already exists in the 'cdk-hn...{redacted}-container-assets-{redacted AWS account}-eu-west-1' repository and cannot be overwritten because the tag is immutable.
❌ Deployment failed: Error: Failed to publish asset 897fca3aa741685c3e503d0370639d91f9566b0db...{redacted}-eu-west-1
at Deployments.publishSingleAsset (C:\Users\alexjuan\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:429:11819)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.publishAsset (C:\Users\alexjuan\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:429:151136)
at async C:\Users\alexjuan\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:429:137092
Failed to publish asset 897fca3aa741685c3e503d037063....{redacted}-eu-west-1
I would appreciate any help, as I need to complete this deployment.
Beta Was this translation helpful? Give feedback.
All reactions