我有一个模板可以生成堆栈,但是我找不到设置属性或其他允许我为创建的EC2实例指定名称的方法。在生成时,名称为空白。
您需要向CloudFormation模板添加一个关键字为Name
的标签,就像这样...
"ec2-instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"ImageId" : "ami-0102022,
"SecurityGroupIds" : [{ "Ref" : "SecurityGroup" }],
"SubnetId" : { "Ref" : "Subnet" },
"InstanceType" : "m1.medium",
"Tags" : [
{"Key" : "Name", "Value" : "Instance name"},
{"Key" : "Environment", "Value" : { "Ref" : "Environment" }},
{"Key" : "Owner", "Value" : { "Ref" : "Owner" }}
]
}
}
PropagateAtLaunch
:如果您希望AWS CloudFormation将标记复制到作为自动缩放组的一部分启动的EC2实例上,则设置为true。 如果您只想将标记附加到自动缩放组而不复制到作为自动缩放组的一部分启动的任何实例,则设置为false。 必需:是。 类型:布尔值。 < 基本上,如果您有一个自动缩放组并且希望将标记添加到实例中,则需要将此属性设置为“true”。 - WispyCloud