【发布时间】:2015-06-25 15:44:59
【问题描述】:
我开始使用 CloudFormation 进行编排/配置,我发现有两种安装包的方法:
第一种方法是在用户数据部分使用 bash 脚本,例如:
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"\n",
[
"#!/bin/bash",
"apt-get update",
"apt-get upgrade -y",
"apt-get install apache2 -y",
"echo \"<html><body><h1>Welcome</h1>\" > /var/www/index.html",
另一种方法是使用cfn-init:
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"yum update -y aws-cfn-bootstrap\n",
"# Install the files and packages from the metadata\n",
"/opt/aws/bin/cfn-init -v ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource WebServerInstance ",
" --configsets Install ",
" --region ", { "Ref" : "AWS::Region" }, "\n"
]]}}
是否有任何理由在 UserData 中使用 cfn-init 而不是 bash?
【问题讨论】:
标签: bash cloud server amazon provisioning