bash - Difference between UserData and cfn-helper with CloudFormation AWS -


i starting use cloudformation orchestration/provisioning , see there 2 ways install packages:

first way bash script in userdata section, example:

"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", 

another way use cfn-init:

"userdata"       : { "fn::base64" : { "fn::join" : ["", [              "yum update -y aws-cfn-bootstrap\n",               "# install files , packages metadata\n",              "/opt/aws/bin/cfn-init -v ",              "         --stack ", { "ref" : "aws::stackname" },              "         --resource webserverinstance ",              "         --configsets install ",              "         --region ", { "ref" : "aws::region" }, "\n"         ]]}} 

is there reasons use cfn-init , not bash in userdata?

actually makes no difference if use bash in userdata or cfn-init. use cnf-init need install package aws-cfn-bootstrap have done , need define

"resources": { "myinstance": { "type": "aws::ec2::instance", "metadata" : { "aws::cloudformation::init" : { "config" : { "packages" : { : }, "groups" : { : }, "users" : { : }, "sources" : { : }, "files" : { : }, "commands" : { : }, "services" : { : } } } }, "properties": { : } } } 

cfn-init clean way things done instead of needing yum install in bash of userdata though same outcome both methods.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -