0
votes

I understand the AWS::CloudFormation::Init block of the template is executed by cfn-init script.

Here is the syntax I use to do so:

/usr/local/bin/cfn-init -v --stack  WebS<erver1 --resource WebServerInstance --region eu-central-1 --configset InstallAndRun && cat /var/log/cfn-init.log

I can do the call via UserData or via SSH.

Now I would like to have the possibility to modify the AWS::CloudFormation::Init part of the template and repeat the cnf-init call via ssh.

Question: Where is the file with the cloud formation code located on my instance, which is executed by cfn-init?

2
Have you been able to find the answer?Ernest Sadykov

2 Answers

2
votes

The cfn-init command uses a configuration file located at /var/lib/cfn-init/data/metadata.json. The JSON file contains the config sets defined in the AWS::CloudFormation::Init block of a Cloud Formation template.

I've confirmed the path above on Amazon Linux 2. The location on other operating systems may be different.

0
votes

All of the cloud init files are in /var/lib/cloud (on Centos 7) and the userdata script is in /var/lib/cloud/instance

See my other answer cloud-init: What is the execution order of cloud-config directives? for general hints on where the source to cloud-init is, execution ordering