大网数据广告活动
服务器运维问答

Why doesn't the aws cloud formation install the packages that I specify?

· 52CE 我爱测

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 …

问题原文

原帖链接 · 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 Metadata in 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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-01-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。