【问题标题】:How can I change LaunchConfig settings with Cloudformation?如何使用 Cloudformation 更改 LaunchConfig 设置?
【发布时间】:2022-01-11 16:08:40
【问题描述】:

我有之前创建的 AutoScale 和 LaunchConfig。我想在 LaunchConfig 中用 Cloudformation 替换 AMI ID。我该怎么做?

我想知道是否有任何示例模板可供我参考?

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation


    【解决方案1】:

    你可以找到简单的例子:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-launchconfig.html#aws-properties-as-launchconfig--examples

       ---
    AWSTemplateFormatVersion: 2010-09-09
    Parameters:
      LatestAmiId:
        Description: Region specific image from the Parameter Store
        Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
        Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2'
      InstanceType:
        Description: Amazon EC2 instance type for the instances
        Type: String
        AllowedValues:
          - t3.micro
          - t3.small
          - t3.medium
        Default: t3.micro
    Resources:
      myLaunchConfig: 
        Type: AWS::AutoScaling::LaunchConfiguration
        Properties:
          ImageId: !Ref LatestAmiId
          SecurityGroups: 
            - Ref: "myEC2SecurityGroup"
          InstanceType: 
            Ref: "InstanceType"
          BlockDeviceMappings: 
            - DeviceName: /dev/sda1
              Ebs: 
                VolumeSize: 30
                VolumeType: "gp3"
            - DeviceName: /dev/sdm
              Ebs: 
                VolumeSize: 100
                DeleteOnTermination: "false"
    

    【讨论】:

    • 我已经有一个现有的模板。我只想在这个创建的堆栈内的启动配置中更改 AMI id。我也想用 Cloudformation 做到这一点。
    • 是否可以将模板或部分模板放在这里/有问题?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 2021-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多