문제

I have the following user-data script in my CloudFormation template:

"UserData" : {"Fn::Base64" : {"Fn::Join" : ["", [
      "#!/bin/bash\n",
      "cd /home/www","\n",
      "sudo su www","\n",
      "git clone git@github.com:company-name/web-app.git -b master2 app","\n",
      "cd app","\n",
      "phing clean prepare configure -Dpropsfile ./build/props/build.ec2.properties","\n",
      "\n",
      "/opt/aws/bin/cfn-signal",
      " -e $?",
      " '", {"Ref" : "WebServerPort"}, "'",
      "\n"
    ]]}},

This runs a preconfigured private ami we based on the default cloudformation template If I launch an instance on my own I can run through the git/build process w/o error But when cloudformation launches a server, it appears as it has never run

도움이 되었습니까?

해결책

Looks like since I created the AMI from an instance that cloudformation launched, it already ran the init scripts and cached them as 'run' thus any new instances would already have those cached files and never run my script.

sudo rm /var/lib/cloud/sem/user-scripts.*
sudo rm /var/lib/cloud/sem/consume_userdata.*

Then making a new AMI allowed it to work for my own init script

Also dont use su, instead chown afterwards :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top