user_data_script Helper
The user_data_script
helper is use to load the UserData scripts. The user_data_script
reads the file that the @user_data_script
variable is set to.
Example
Let’s use an example to explain how it works. Say you have a template with an EC2 instance resource with the UserData property configured:
resource("Instance", "AWS::EC2::Instance",
InstanceType: ref("InstanceType"),
UserData: base64(sub(user_data_script)),
)
In the variables file, set the @user_data_script
variable to the path of the script.
configs/demo/variables/development.rb:
@user_data_script = "configs/demo/user_data/bootstrap.sh"
Make sure that the script exists. Example:
configs/demo/user_data/bootstrap.sh
#!/bin/bash
/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource Instance --region ${AWS::Region}
uptime
Edit this page
See a typo or an error? You can improve this page. This website is available on GitHub and contributions are encouraged and welcomed. We love pull requests from you!
- Suggest an edit to this page (here's the contributing guide).
- Open an issue about this page to report a problem.