I want to define multiple AWS Batch jobs that all use the same environment variables defined in Secrets Manager. I understand CloudFormation does not supports YAML anchors and aliases. Is there a way to define the 'Secrets' configuration as a reusable block?
example: i don't want to define the "Secrets" manytimes for each job. (very long template)
BatchRCJob01:
Type: AWS::Batch::JobDefinition
Properties:
...
EcsProperties:
TaskProperties:
- ...
Containers:
- Name: TestContainer01
...
Secrets:
- Name: APP_MODE_ENV
ValueFrom: "arn:aws:secretsmanager:ap-northeast-1:123456789:secret:dev/test-us7Vjm:APP_MODE_ENV::"
- Name: APP_API_DATABASE_HOST
ValueFrom: "arn:aws:secretsmanager:ap-northeast-1:123456789:secret:dev/test-us7Vjm:APP_API_DATABASE_HOST::"
- Name: APP_API_DATABASE_NAME
ValueFrom: "arn:aws:secretsmanager:ap-northeast-1:123456789:secret:dev/test-us7Vjm:APP_API_DATABASE_NAME::"
- Name: APP_API_DATABASE_PASSWORD
ValueFrom: "arn:aws:secretsmanager:ap-northeast-1:123456789:secret:dev/test-us7Vjm:APP_API_DATABASE_PASSWORD::"
- Name: APP_API_DATABASE_USERNAME
ValueFrom: "arn:aws:secretsmanager:ap-northeast-1:123456789:secret:dev/test-us7Vjm:APP_API_DATABASE_USERNAME::"
- Name: KEY_BASE
ValueFrom: "arn:aws:secretsmanager:ap-northeast-1:123456789:secret:dev/test-us7Vjm:KEY_BASE::"
# and many others secret
...
DependsOn: []
BatchRCJob02:
Type: AWS::Batch::JobDefinition
Properties:
...
EcsProperties:
TaskProperties:
- ...
Containers:
- Name: TestContainer02
...
Secrets:
- Name: APP_MODE_ENV
ValueFrom: "arn:aws:secretsmanager:ap-northeast-1:123456789:secret:dev/test-us7Vjm:APP_MODE_ENV::"
- Name: APP_API_DATABASE_HOST
ValueFrom: "arn:aws:secretsmanager:ap-northeast-1:123456789:secret:dev/test-us7Vjm:APP_API_DATABASE_HOST::"
- Name: APP_API_DATABASE_NAME
ValueFrom: "arn:aws:secretsmanager:ap-northeast-1:123456789:secret:dev/test-us7Vjm:APP_API_DATABASE_NAME::"
- Name: APP_API_DATABASE_PASSWORD
ValueFrom: "arn:aws:secretsmanager:ap-northeast-1:123456789:secret:dev/test-us7Vjm:APP_API_DATABASE_PASSWORD::"
- Name: APP_API_DATABASE_USERNAME
ValueFrom: "arn:aws:secretsmanager:ap-northeast-1:123456789:secret:dev/test-us7Vjm:APP_API_DATABASE_USERNAME::"
- Name: KEY_BASE
ValueFrom: "arn:aws:secretsmanager:ap-northeast-1:123456789:secret:dev/test-us7Vjm:KEY_BASE::"
# and many others secret
...
DependsOn: []
...
# and many others job
- The stack deploy error when using yaml anchor/alias definiton