AWS CloudFormation Command Line Operations: Difference between revisions
Jump to navigation
Jump to search
Line 22: | Line 22: | ||
=Update a Stack= | =Update a Stack= | ||
{{External|[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-direct.html Updating Stacks Directly]}} | |||
aws cloudformation update-stack --stack-name ''stack-name'' --template-body file://.../''stack-template''.yml [--parameters ParameterKey=Parm1,ParameterValue=test1 ParameterKey=Parm2,ParameterValue=test2] | aws cloudformation update-stack --stack-name ''stack-name'' --template-body file://.../''stack-template''.yml [--parameters ParameterKey=Parm1,ParameterValue=test1 ParameterKey=Parm2,ParameterValue=test2] | ||
Updates a stack as specified in the template. After the call completes successfully, the stack update starts. | Updates a stack as specified in the template. After the call completes successfully, the stack update starts. | ||
aws cloudformation update-stack --stack-name mystack --use-previous-template --parameters ... | |||
=Delete a Stack= | =Delete a Stack= |
Revision as of 20:51, 21 March 2019
Internal
Validate Templates
aws cloudformation validate-template --template-body file://.../stack-template.yml
Create a Stack
aws cloudformation create-stack --stack-name stack-name --template-body file://.../stack-template.yml [--parameters ParameterKey=Parm1,ParameterValue=test1 ParameterKey=Parm2,ParameterValue=test2]
If the template is supposed to create IAM roles, the command line will fail with a message similar to "An error occurred (InsufficientCapabilitiesException) when calling the CreateStack operation: Requires capabilities : [CAPABILITY_NAMED_IAM]", unless the capability is explicitly provided on command line with:
aws cloudformation create-stack --capabilities CAPABILITY_NAMED_IAM ...
A stack can only be created once, a subsequent invocation of the 'create-stack' command will result in:
An error occurred (AlreadyExistsException) when calling the CreateStack operation: Stack [api-experiments] already exists
Update a Stack
aws cloudformation update-stack --stack-name stack-name --template-body file://.../stack-template.yml [--parameters ParameterKey=Parm1,ParameterValue=test1 ParameterKey=Parm2,ParameterValue=test2]
Updates a stack as specified in the template. After the call completes successfully, the stack update starts.
aws cloudformation update-stack --stack-name mystack --use-previous-template --parameters ...
Delete a Stack
aws cloudformation delete-stack --stack-name stack-name
Describe a Stack
aws cloudformation describe-stacks
Obtaining the Template of an Existing Stack
This is useful when we want to apply an update, but we don't have the original template document.
aws cloudformation get-template
Organizatorium
aws cloudformation package --template-file deployment-stack.yaml --s3-bucket $TARGET_BUCKET --output-template-file new-deployment-stack.yaml