Reputation: 6292
Got a little problem, so part of my json file I want to run a command to update all the packages the following command is:
"commands" : {
"update_yum_packages" : {
"command" : "sudo yum update -y"
}
},
Now if I remove this from my json file the stack will create with no issues, however when I add the command I get an error from AWS::CloudFormation::WaitCondition. I have set the timeout to 1200 is there something clearly wrong here ?
I can run the command fine once I ssh onto the new instance.
Upvotes: 0
Views: 2610
Reputation: 16837
This yaml should do the same thing without you having to directly call sudo
#cloud-config
---
package_update: true
package_upgrade: true
package_reboot_if_required: true
Upvotes: 0
Reputation: 7012
You can have a look at the log files in /var/log/cloud-init-output.log.
You will see that it complains about running a sudo command without a tty:
cloud-init-output.log:sudo: sorry, you must have a tty to run sudo
The user data is run as root, you don't need to use "sudo". And using sudo will fail, and make the cloud-init process fail.
So just use:
"commands" : {
"update_yum_packages" : {
"command" : "yum update -y"
}
},
Upvotes: 3