AWS Secrets Manager automatically adds a 6 character suffix to any generated secret name. Since the suffix is generated, it will be different across environments (i.e. prod, dev, etc).
The suffix is there for a good reason, but what is a best practice for looking up secrets across environments by arn when the keys will differ slightly.
Example: As part of ECS taskDef.json you can specify an arn reference like so:
{
"containerDefinitions": [{
"secrets": [{
"name": "environment_variable_name",
"valueFrom": "arn:aws:secretsmanager:region:aws_account_id:secret:secret_name-AbCdEf"
}]
}]
}
Knowing that just the suffix AbCdEf
will differ between environments, what is the best approach for specifying the suffix dynamically per environment in taskDef.json?
So far I am thinking a custom env variable that can be used with string interpolation to build it like this: "arn:aws:secretsmanager:region:aws_account_id:secret:secret_name-${code}"
.
However, is there a more elegant way offered via AWS?