Can I define tags as a parameter in parameters section AWS CloudFormation template and use it in each created resource?
My current template:
AWSTemplateFormatVersion: 2010-09-09
Description: "Some information"
Parameters:
Test1:
Type: String
Description: Test1
Default: t1
Test2:
Type: String
Description: Test2
Default: t2
...
LBSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription: "Enable access to app loadbalancer"
Tags:
- Key: Name
Value: !Join
- ""
- - !Ref Test1
- !Ref Test2
- Key: Test1
Value: !Ref Test1
- Key: Test2
Value: !Ref Test2
I use the same tags for any other resourses(AWS::ElasticLoadBalancing::LoadBalancer, AWS::AutoScaling::AutoScalingGroup etc.), and it seems like duplicated code (each time when I create a new resource). Can I craft something like this?:
AWSTemplateFormatVersion: 2010-09-09
Description: "Some information"
Parameters:
Test1:
Type: String
Description: Test1
Default: t1
Test2:
Type: String
Description: Test2
Default: t2
Tag:
#define all tags, which I created above
...
LBSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription: "Enable access to app loadbalancer"
Tags: !Ref Tag
...
Unfortunately, I didn't find any information about it on https://docs.aws.amazon.com/