AWS Cloudformation:从自动扩展启动配置中标记块设备

AWS Cloudformation: Tagging block device from auto-scaling launch configuration

我已经通过 Cloudformation 模板创建了一个自动缩放组及其启动配置。

Autoscaling 组只有一个名为 'name' 的标签。 启动配置中的 ec2 实例有块设备映射,如下所示:

ASGLaunchConfiguration:
    Type: AWS::AutoScaling::LaunchConfiguration
    DependsOn: CloudwatchConfigSsm
    Properties:
      ImageId: !Ref PresentationAMIId
      InstanceType: !Ref PresentationInstanceType
      AssociatePublicIpAddress: false
      BlockDeviceMappings:
        - DeviceName: /dev/xvda
          Ebs:
            VolumeSize: 20
            VolumeType: gp2
            Encrypted: true

但问题是在关联的自动缩放组中定义的名为 'name' 的标签不会传播到创建的 EBS 卷。 自动缩放组中的标签定义如下:

Tags:
        - Key: 'Name'
          Value: !Sub 'presentation-server-${Env}'
          PropagateAtLaunch: true

此外,我还需要添加一些其他重要的标签。 我怎样才能做到这一点?

更新:

我创建了以下启动模板:

ASGLaunchTemplate:
    Type: AWS::EC2::LaunchTemplate
    DependsOn: CloudwatchConfigSsm
    Properties:
      LaunchTemplateName: !Sub 'ec2-launch-template-${Region}-${Env}'
      TagSpecifications:
        - ResourceType: instance
          Tags:
          - Key: System
            Value: 'xxx'
          - Key: Env
            Value: !Sub '${Env}'
          - Key: EnvNumber
            Value: '01'
          - Key: Country
            Value: !Sub '${Region}'
          - Key: Company
            Value: 'xxx'
          - Key: Global
            Value: 'all'
          - Key: CostCenter
            Value: 'xxxx'
          - Key: 'Name'
            Value: !Sub 'presentation-server-${Env}'
        - ResourceType: volume
          Tags:
          - Key: 'Name'
            Value: !Sub 'presentation-server-ebs-volume-${Env}'
          - Key: System
            Value: 'xxx'
          - Key: Env
            Value: !Sub '${Env}'
          - Key: EnvNumber
            Value: '01'
          - Key: Country
            Value: !Sub '${Region}'
          - Key: Company
            Value: 'xxx'
          - Key: Global
            Value: 'all'
          - Key: CostCenter
            Value: 'xxxx'
      LaunchTemplateData:
        ImageId: !Ref PresentationAMIId
        InstanceType: !Ref PresentationInstanceType
        NetworkInterfaces:
          - AssociatePublicIpAddress: false
        BlockDeviceMappings:
          - DeviceName: /dev/xvda
            Ebs:
              VolumeSize: 20
              VolumeType: gp2
              Encrypted: true

更新堆栈时出现以下错误:

You can specify only one TagSpecification parameter in the request. Ensure that the request includes only one TagSpecification parameter and try again.

应该是:

ASGLaunchTemplate:
    Type: AWS::EC2::LaunchTemplate
    DependsOn: CloudwatchConfigSsm
    Properties:
      LaunchTemplateName: !Sub 'ec2-launch-template-${Region}-${Env}'
      LaunchTemplateData:
        ImageId: !Ref PresentationAMIId
        TagSpecifications:
          - ResourceType: instance
            Tags:
            - Key: System
              Value: 'xxx'
            - Key: Env
              Value: !Sub '${Env}'
            - Key: EnvNumber
              Value: '01'
            - Key: Country
              Value: !Sub '${Region}'
            - Key: Company
              Value: 'xxx'
            - Key: Global
              Value: 'all'
            - Key: CostCenter
              Value: 'xxxx'
            - Key: 'Name'
              Value: !Sub 'presentation-server-${Env}'
          - ResourceType: volume
            Tags:
            - Key: 'Name'
              Value: !Sub 'presentation-server-ebs-volume-${Env}'
            - Key: System
              Value: 'xxx'
            - Key: Env
              Value: !Sub '${Env}'
            - Key: EnvNumber
              Value: '01'
            - Key: Country
              Value: !Sub '${Region}'
            - Key: Company
              Value: 'xxx'
            - Key: Global
              Value: 'all'
            - Key: CostCenter
              Value: 'xxxx'        
        InstanceType: !Ref PresentationInstanceType
        NetworkInterfaces:
          - AssociatePublicIpAddress: false
        BlockDeviceMappings:
          - DeviceName: /dev/xvda
            Ebs:
              VolumeSize: 20
              VolumeType: gp2
              Encrypted: true