boto3_cfn

Manage CloudFormation stacks using boto3.

Renamed from boto_cfn to boto3_cfn and updated to call the refactored boto3_cfn execution module.

Create and destroy CloudFormation stacks. Be aware that this interacts with Amazon’s services, and so may incur charges.

depends:
  • boto3 >= 1.28.0

  • botocore >= 1.31.0

This module uses boto3, which can be installed via package, or pip.

This module accepts explicit CloudFormation credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no further configuration is necessary. More Information available at:

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html

If IAM roles are not used you need to specify them either in the minion’s config file or as a profile. For example, to specify them in the minion’s config file:

cfn.keyid: GKTADJGHEIQSXMKKRBJ08H
cfn.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

It’s also possible to specify key, keyid and region via a profile, either as a passed in dict, or as a string to pull from pillars or minion config:

myprofile:
    keyid: GKTADJGHEIQSXMKKRBJ08H
    key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
    region: us-east-1
stack-present:
  boto3_cfn.present:
    - name: mystack
    - template_body: salt://base/mytemplate.json
    - disable_rollback: true
    - region: eu-west-1
    - keyid: 'AKIAJHTMIQ2ASDFLASDF'
    - key: 'fdkjsafkljsASSADFalkfjasdf'
stack-absent:
  boto3_cfn.absent:
    - name: mystack

Added in version 1.0.0.

saltext.boto3.states.boto3_cfn.__virtual__()[source]

Only load if the boto3_cfn execution module is available.

saltext.boto3.states.boto3_cfn.present(name, template_body=None, template_url=None, parameters=None, notification_arns=None, disable_rollback=None, timeout_in_minutes=None, capabilities=None, tags=None, on_failure=None, stack_policy_body=None, stack_policy_url=None, use_previous_template=None, stack_policy_during_update_body=None, stack_policy_during_update_url=None, region=None, key=None, keyid=None, profile=None)[source]

Ensure cloud formation stack is present.

name (string) - Name of the stack.

template_body (string) - Structure containing the template body. Can also be loaded from a file by using salt://.

template_url (string) - Location of file containing the template body. The URL must point to a template located in an S3 bucket in the same region as the stack.

parameters (list) - A list of (key, value) tuples or {"ParameterKey": ..., "ParameterValue": ...} dicts that specify input parameters for the stack. A 3-tuple (key, value, use_previous_value) may be used to specify the UsePreviousValue option.

notification_arns (list) - The Simple Notification Service (SNS) topic ARNs to publish stack related events.

disable_rollback (bool) - Indicates whether or not to rollback on failure.

timeout_in_minutes (integer) - The amount of time that can pass before the stack status becomes CREATE_FAILED.

capabilities (list) - The list of capabilities you want to allow in the stack.

tags (dict or list) - Tags to associate with this stack. A dict is converted to the boto3 [{"Key": ..., "Value": ...}] form.

on_failure (string) - One of DO_NOTHING, ROLLBACK, or DELETE.

stack_policy_body (string) - Structure containing the stack policy body. Can also be loaded from a file by using salt://.

stack_policy_url (string) - Location of a file containing the stack policy.

use_previous_template (boolean) - Set to True to use the previous template instead of uploading a new one via template_body or template_url.

stack_policy_during_update_body (string) - Temporary overriding stack policy body used during an update. Can also be loaded from a file by using salt://.

stack_policy_during_update_url (string) - Location of a file containing the temporary overriding stack policy.

region (string) - Region to connect to.

key (string) - Secret key to be used.

keyid (string) - Access key to be used.

profile (dict) - A dict with region, key and keyid, or a pillar key (string) that contains a dict with region, key and keyid.

Example:

ensure-present:
  boto3_cfn.present:
    - name: example
saltext.boto3.states.boto3_cfn.absent(name, region=None, key=None, keyid=None, profile=None)[source]

Ensure cloud formation stack is absent.

name (string) - The name of the stack to delete.

region (string) - Region to connect to.

key (string) - Secret key to be used.

keyid (string) - Access key to be used.

profile (dict) - A dict with region, key and keyid, or a pillar key (string) that contains a dict with region, key and keyid.

Example:

ensure-absent:
  boto3_cfn.absent:
    - name: example