aws / copilot-cli

The AWS Copilot CLI is a tool for developers to build, release and operate production ready containerized applications on AWS App Runner or Amazon ECS on AWS Fargate.
https://aws.github.io/copilot-cli/
Apache License 2.0
3.51k stars 408 forks source link

Expose COPILOT_DOCKER_VERSION as predefined variable for task #5169

Open AlexeiZenin opened 1 year ago

AlexeiZenin commented 1 year ago

I am trying to add DD_VERSION to my task in AWS Copilot as outlined here: https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/java/?tab=containers. This allows me to track errors/requests between versions on my dashboards, something that is critical for PROD deploys.

I don't see an existing way to set the DD_VERSION as an environment variable for my ECS Fargate task where the value is set to the tag of the the image for the service deploy.

Can this be done in some other way or does this functionality need to be added?

I am looking to be able to do something like this:

variables:
  DD_VERSION: ${COPILOT_DOCKER_VERSION}
huanjani commented 1 year ago

Hi, @AlexeiZenin!

Sorry for the delay. We don't have a native way to do this, but it's a great suggestion. I'll add the appropriate labels.

In the meantime, a couple options that may work for you: -- Are you using a Copilot pipeline? If so, you can add some lines in the buildspec to grab/export the tag. This is the line that generates the tag from the CodeBuild build ID:

tag=$(echo ${CODEBUILD_BUILD_ID##*:}-$env | sed 's/:/-/g' | rev | cut -c 1-128 | rev)

-- Set the git commit id as an env var locally each time you're going to run svc deploy and use shell env vars to refer to them in your manifest.

Thanks!