Search code examples
aws-cliamazon-ecscircleciaws-secrets-manager

Managing secrets with aws cli register task definition


I use circleci to build and push the application to aws. I have now managed to create and register a new task definition in the circleci config using the aws cli. This works well. The problem or case i´am having is how do I overwrite the placeholder values using the cli?

Here is how i read the task definition:

aws ecs register-task-definition --cli-input-json file://.circleci/taskdefinition.json

The task definition file:

{
  "containerDefinitions": [
    {
      "cpu": 10,
      "environment": [
        {
          "name": "Secret_api_key",
          "value": "placeholder_value"
        }
      ],
      "image": "<Image>",
      "name": "app-dev"
    }
  ],
  "placementConstraints": [],
  "memory": "512",
  "family": "pp-dev",
  "networkMode": "bridge"
}

What I want to know is, how do I update the placeholder_value which I have retrieved from aws secrets manager?


Solution

  • Use sed to replace the placeholders with secret valuables from private environment variables.