Skip
Skip

Reputation: 6521

Where is CloudFormation template located on the instance, which is called by cloud-init?

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?

Upvotes: 0

Views: 1422

Answers (2)

Gunnar
Gunnar

Reputation: 678

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.

Upvotes: 3

Vorsprung
Vorsprung

Reputation: 34307

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

Upvotes: 0

Related Questions