[英]EC2 instance launched through AutoScaling group drains automatically quickly
[英]How to add files for the ec2 instance which is launched with autoscaling group?
我看到我們可以使用Cloudformation:Init通過Metadata將文件添加到ec2實例,如下所示。
"Resources": {
"MyInstance": {
"Type": "AWS::EC2::Instance",
"Metadata" : {
"AWS::CloudFormation::Init" : {
"config" : {
"packages" : {
:
},
"groups" : {
:
},
"users" : {
:
},
"sources" : {
:
},
"files" : {
:
},
"commands" : {
:
},
"services" : {
:
}
}
}
}
}}
但是,當我要使用自動縮放組啟動實例時,該怎么辦? 我嘗試將啟動配置下的元數據添加為EC2。
在Auto Scaling組使用的AWS::AutoScaling::LaunchConfiguration
資源中包括Metadata
結構。
"LaunchConfig" : {
"Type" : "AWS::AutoScaling::LaunchConfiguration",
"Metadata" : {
"AWS::CloudFormation::Init" : {
"config" : {
"files" : {
}
}
}
},
"Properties" : {
}
}
這里有一個樣本可以做到這一點:
看一下“ LaunchConfig”資源。
現在,它運作良好。 啟動ec2后,我可以運行cfn-int -s <stack_name> -r <resource> --region ..
來同步資源。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.