I am setting up ECS Services to launch my application which speaks to the RDS Database server. I need to pass the Database access properties such as username, password, dbname etc to the application codes running in the FARGATE instances. So to pass them i have created these parameters in the parameter store, but i need to find a way to get them from the parameter store and pass it to the ECS task definitons env variable properties?
In the ECS Task definitions, i have tried to modify the JSON file environment property with the parameters such as "name: and "valueFrom", but seems that the "valueFrom:" is not being accepted in the JSON file, it pops out an error saying "Cannot read property 'replace' of undefined"
"environment": [
{
"name": "POSTGRES_DB",
"valueFrom": "PROD_POSTGRES_DB"
}
],
I expect that the POSTGRES_DB parameter reads the values from the PROD_POSTGRES_DB defined in parameter store of AWS
When you use SSM Parameter Store in ECS Task Definition for the valueFrom
environment variables, it creates separate secrets
section under containerDefinitions. So, it will look like below.
"containerDefinitions": [
{
"secrets": [
{
"name": "POSTGRES_DB",
"valueFrom": "PROD_POSTGRES_DB"
}
],
"environment": [
{
"valueFrom": "myKey",
"name": "myValue"
}
],
}
]
For the normal value
environment variables, it will be usual environment
json array.
Note -