问题原文
原帖链接 · batman · CC BY-SA 3.0
I'm very new to the AWS services. I'm trying to use the AWS cloud formation and I created a template. The template is error free and I am able to create machines using that.
But I have added some config in the template such that it installs tomcat, git and other things during startup. But that doesn't happen for me.
Here is a part of code I used for installing tomcat :
"Resources": {
"Tomcat": {
"Type": "AWS::EC2::Instance",
"Metadata": {
"AWS::CloudFormation::Init": {
"config": {
"packages": {
"apt": {
"tomcat6": [],
"git": [],
}
}
}
}
},
But when I log into the machine neither tomcat nor git have been installed!
Thanks in advance.
社区高分解答
原帖链接 · dialt0ne · CC BY-SA 3.0
I believe your problem here is confusion around that cloud-init is not the same as cfn-init.
cloud-init is the tool that started as part of the Ubuntu AWS AMIs that allow the interpretation of the EC2 user-data component of the instance meta-data. Amazon Linux adopted this tool as well and built it into their AMI.
cfn-init is part of a different toolset called CloudFormation Helper Scripts created by AWS for Amazon Linux that can read an additional section named
Metadatain your CloudFormation template.
So, Ubuntu and Amazon Linux AMIs both have the cloud-init tools preinstalled to access the user-data, but only Amazon Linux has the CloudFormation Helper Scripts preinstalled e.g. cfn-init to access the CloudFormation Metadata.
However, AWS does distribute packages that you can use to read the CloudFormation Metadata. Specifically, look at this template for how you can use a cloud-init user-data script to install python-setuptools, download the CloudFormation Helper Scripts, install them using easy_install and then invoke cfn-init.
Note: There are other distributions or AMIs that might support cloud-init or cfn-init, but I'm just covering the general cases here.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
