| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
The cfn-init helper script reads template metadata from the AWS::CloudFormation::Init key and acts accordingly to:
Fetch and parse metadata from CloudFormation
Install packages
Write files to disk
Enable/disable and start/stop services
Note
cfn-init does not require credentials, so you do not need to use the
--access-key, --secret-key, --role, or
--credential-file options.
For information about the template metadata that cfn-init uses, see AWS::CloudFormation::Init.
cfn-init --stack|-sstack.name.or.id\ --resource|-rlogical.resource.id\ --regionregion--access-keyaccess.key\ --secret-keysecret.key\ --rolerolename\ --credential-file|-fcredential.file\ --configsets|-cconfig.sets\ --url|-uservice.url\ -v
| Name | Description | Required |
|---|---|---|
|
|
Name of the Stack. Type: String. Default: None Example: |
Yes |
|
|
The logical resource ID of the resource that contains the metadata. Type: String. Example: |
Yes |
|
|
The region to derive the CloudFormation URL from. Type: String. Default: None Example: |
No |
|
|
AWS Access Key for an account with permission to call DescribeStackResource on CloudFormation. Type: String. Condition: The credential file parameter supercedes this parameter. |
Conditional |
|
|
AWS Secret Key that corresponds to the specified AWS Access Key. Type: String. Condition: The credential file parameter supercedes this parameter. |
Conditional |
|
|
The IAM role name. Type: String. Condition: The credential file parameter supercedes this parameter. | |
|
|
A file that contains both a secret key and an access key. Type: String. Condition: The credential file parameter supercedes the --access-key and --secret-key parameters. |
Conditional |
|
|
A comma-separated list of configsets to run (in order). Type: String. Default: |
No |
|
|
The CloudFormation service URL to hit. Type: String. Condition: The credential file parameter supercedes the --access-key and --secret-key parameters. |
No |
|
|
Verbose output. This is useful for debugging cases where cfn-init is failing to initialize. Note To debug initialization events, you should turn DisableRollback on. You can do this by using the CloudFormation console, selecting Show Advanced Options, and then setting "Rollback on failure" to "No". You can then SSH into the console and read the logs at /var/log/cfn-init.log. |
No |
The following snippet is associated with a resource named WebServer.
"/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackName" },
" -r WebServer ",
" --region ", { "Ref" : "AWS::Region" }, \n",Several AWS CloudFormation sample templates use cfn-init, including the following templates.