Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github actions - pass secret variables to render ECS task definition action

In order to deploy new task to ECS im using amazon-ecs-render-task-definition GitHub action. This action receives a task-definition.json as a parameter. This JSON contain secrets that i dont want to push, is there a way to inject some parameter to this JSON? Maybe from aws secrets manager?

For example - task-definition.json

{
 "containerDefinitions": [
  {
   "name": "wordpress",
   "links": [
     "mysql"
   ],
  "image": "wordpress",
  "essential": true,
  "portMappings": [
    {
      "containerPort": 80,
      "hostPort": 80
    }
  ],
  "memory": 500,
  "cpu": 10
},
{
  "environment": [
    {
      "name": "MYSQL_ROOT_PASSWORD",
      "value": ****"password"**** // ITS A SECRET!
    }
  ],
  "name": "mysql",
  "image": "mysql",
  "cpu": 10,
  "memory": 500,
  "essential": true
}], 
 "family": "hello_world" }
like image 275
Benny67b Avatar asked Mar 03 '23 01:03

Benny67b


1 Answers

Apparently there is a build in solution for using aws-scrent-manager secrets:

"secrets": [
    {
      "name": "DATABASE_PASSWORD",
      "valueFrom": "arn:aws:ssm:us-east-1:awsExampleAccountID:parameter/awsExampleParameter"
    }
  ]

https://aws.amazon.com/premiumsupport/knowledge-center/ecs-data-security-container-task/

like image 67
Benny67b Avatar answered Mar 05 '23 15:03

Benny67b