I am using Terraform to deploy an ECS task and would like to use AWS SSM Parameters within the container definition of the ECS task.
I have 3 SSM parameters that I would like to use to override the default properties defined in service.json. (PORT, TEST_PROP_1, TEST_PROP_2)
Is there a way for me to provide the ARN of these SSM parameters for the container definition environment variables?
Terraform resource:
resource "aws_ecs_task_definition" "testapp" {
family = "testapp"
network_mode = "awsvpc"
cpu = 256
memory = 512
container_definitions = file("../modules/ecs_service/task-definitions/service.json")
requires_compatibilities = [
"FARGATE"
]
execution_role_arn = "arn:aws:iam::redacted:role/ecsTaskExecutionRole"
task_role_arn = "arn:aws:iam::redacted:role/ecsTaskExecutionRole"
}
service.json
[
{
"name": "testapp",
"image": "redacted/demoapp:latest",
"portMappings": [
{
"containerPort": 59817,
"hostPort": 59817,
"protocol": "tcp"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "testappLG",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "devtest"
}
},
"Environment": [
{
"Name": "PORT",
"Value": "9001"
},
{
"Name": "TEST_PROP_1",
"Value": "Override value - test prop 1"
},
{
"Name": "TEST_PROP_2",
"Value": "Override value - test prop 2"
}
]
}
]