I have a cloudformation template and I would like to know if it is possible to apply conditional tagging according to the environment (dev/test/prod).
AWSTemplateFormatVersion: "2010-09-09"
Description: Some description
Conditions:
CreateProdResources: !Equals [ !Ref Environment, "prod" ]
CreateDevResources: !Equals [ !Ref Environment, "dev" ]
CreateTestResources: !Equals [ !Ref Environment, "test"]
Parameters:
Environment:
Type: String
Description: Environment Used
ConstraintDescription: Must be either dev, test, or prod
AllowedValues:
- dev
- test
- prod
ApplicationDeploymentDev:
Type: String
Description: 'Enter ApplicationDeployment Tag'
Default: Some default dev value
ApplicationDeploymentTest:
Type: String
Description: 'Enter ApplicationDeployment Tag'
Default: Some default test value
ApplicationDeploymentProd:
Type: String
Description: 'Enter ApplicationDeployment Tag'
Default: Some default prod value
Tags:
In the Tags section I'd like to have each key-value tag pair in sync with the environment I am choosing while deploying. So for example if environment = dev then
Tags:
Key: ApplicationDeploymentDev
Value: Some default dev value
Has anyone achieved doing something similar?
You can nest If
:
Tags:
!If
- CreateDevResources
- [{Key: ApplicationDeploymentDev, Value: Some default dev value }]
- !If
- CreateProdResources
- [{Key: ApplicationDeploymentProd, Value: Some default Prod value }]
- [{Key: ApplicationDeploymentTest, Value: Some default Test value }]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.