Note

You are viewing the documentation for an older version of boto (boto2).

Boto3, the next version of Boto, is now stable and recommended for general use. It can be used side-by-side with Boto in the same project, so it is easy to start using Boto3 in your existing projects as well as new projects. Going forward, API updates and all new feature work will be focused on Boto3.

For more information, see the documentation for boto3.

cloudformation

boto.cloudformation

boto.cloudformation.connect_to_region(region_name, **kw_params)

Given a valid region name, return a boto.cloudformation.CloudFormationConnection.

Parameters:region_name (str) – The name of the region to connect to.
Return type:boto.cloudformation.CloudFormationConnection or None
Returns:A connection to the given region, or None if an invalid region name is given
boto.cloudformation.regions()

Get all available regions for the CloudFormation service.

Return type:list
Returns:A list of boto.RegionInfo instances

boto.cloudformation.connection

class boto.cloudformation.connection.CloudFormationConnection(aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, port=None, proxy=None, proxy_port=None, proxy_user=None, proxy_pass=None, debug=0, https_connection_factory=None, region=None, path='/', converter=None, security_token=None, validate_certs=True, profile_name=None)

AWS CloudFormation AWS CloudFormation enables you to create and manage AWS infrastructure deployments predictably and repeatedly. AWS CloudFormation helps you leverage AWS products such as Amazon EC2, EBS, Amazon SNS, ELB, and Auto Scaling to build highly-reliable, highly scalable, cost effective applications without worrying about creating and configuring the underlying AWS infrastructure.

With AWS CloudFormation, you declare all of your resources and dependencies in a template file. The template defines a collection of resources as a single unit called a stack. AWS CloudFormation creates and deletes all member resources of the stack together and manages all dependencies between the resources for you.

For more information about this product, go to the `CloudFormation Product Page`_.

Amazon CloudFormation makes use of other AWS products. If you need additional technical information about a specific AWS product, you can find the product’s technical documentation at `http://aws.amazon.com/documentation/`_.

APIVersion = '2010-05-15'
DefaultRegionEndpoint = 'cloudformation.us-east-1.amazonaws.com'
DefaultRegionName = 'us-east-1'
cancel_update_stack(stack_name_or_id=None)

Cancels an update on the specified stack. If the call completes successfully, the stack will roll back the update and revert to the previous stack configuration. Only stacks that are in the UPDATE_IN_PROGRESS state can be canceled.

Parameters:stack_name_or_id (string) – The name or the unique identifier associated with the stack.
create_stack(stack_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)

Creates a stack as specified in the template. After the call completes successfully, the stack creation starts. You can check the status of the stack via the DescribeStacks API. Currently, the limit for stacks is 20 stacks per account per region.

Parameters:stack_name (string) –
The name associated with the stack. The name must be unique within your
AWS account.
Must contain only alphanumeric characters (case sensitive) and start
with an alpha character. Maximum length of the name is 255 characters.
Parameters:template_body (string) – Structure containing the template body. (For more information, go to `Template Anatomy`_ in the AWS CloudFormation User Guide.)
Conditional: You must pass TemplateBody or TemplateURL. If both are
passed, only TemplateBody is used.
Parameters:template_url (string) – Location of file containing the template body. The URL must point to a template (max size: 307,200 bytes) located in an S3 bucket in the same region as the stack. For more information, go to the `Template Anatomy`_ in the AWS CloudFormation User Guide.
Conditional: You must pass TemplateURL or TemplateBody. If both are
passed, only TemplateBody is used.
Parameters:
  • parameters (list) – A list of key/value tuples that specify input parameters for the stack.
  • disable_rollback (boolean) – Set to True to disable rollback of the stack if stack creation failed. You can specify either DisableRollback or OnFailure, but not both.

Default: False

Parameters:
  • timeout_in_minutes (integer) – The amount of time that can pass before the stack status becomes CREATE_FAILED; if DisableRollback is not set or is set to False, the stack will be rolled back.
  • notification_arns (list) – The Simple Notification Service (SNS) topic ARNs to publish stack related events. You can find your SNS topic ARNs using the `SNS console`_ or your Command Line Interface (CLI).
  • capabilities (list) – The list of capabilities that you want to allow in the stack. If your template contains certain resources, you must specify the CAPABILITY_IAM value for this parameter; otherwise, this action returns an InsufficientCapabilities error. The following resources require you to specify the capabilities parameter: `AWS::CloudFormation::Stack`_, `AWS::IAM::AccessKey`_, `AWS::IAM::Group`_, `AWS::IAM::InstanceProfile`_, `AWS::IAM::Policy`_, `AWS::IAM::Role`_, `AWS::IAM::User`_, and `AWS::IAM::UserToGroupAddition`_.
  • on_failure (string) – Determines what action will be taken if stack creation fails. This must be one of: DO_NOTHING, ROLLBACK, or DELETE. You can specify either OnFailure or DisableRollback, but not both.

Default: ROLLBACK

Parameters:stack_policy_body (string) – Structure containing the stack policy body. (For more information, go to ` Prevent Updates to Stack Resources`_ in the AWS CloudFormation User Guide.)
If you pass StackPolicyBody and StackPolicyURL, only
StackPolicyBody is used.
Parameters:
  • stack_policy_url (string) – Location of a file containing the stack policy. The URL must point to a policy (max size: 16KB) located in an S3 bucket in the same region as the stack. If you pass StackPolicyBody and StackPolicyURL, only StackPolicyBody is used.
  • tags (dict) – A set of user-defined Tags to associate with this stack, represented by key/value pairs. Tags defined for the stack are propagated to EC2 resources that are created as part of the stack. A maximum number of 10 tags can be specified.
delete_stack(stack_name_or_id)

Deletes a specified stack. Once the call completes successfully, stack deletion starts. Deleted stacks do not show up in the DescribeStacks API if the deletion has been completed successfully.

Parameters:stack_name_or_id (string) – The name or the unique identifier associated with the stack.
describe_stack_events(stack_name_or_id=None, next_token=None)

Returns all stack related events for a specified stack. For more information about a stack’s event history, go to `Stacks`_ in the AWS CloudFormation User Guide. Events are returned, even if the stack never existed or has been successfully deleted.

Parameters:stack_name_or_id (string) – The name or the unique identifier associated with the stack.

Default: There is no default value.

Parameters:next_token (string) – String that identifies the start of the next list of events, if there is one.

Default: There is no default value.

describe_stack_resource(stack_name_or_id, logical_resource_id)

Returns a description of the specified resource in the specified stack.

For deleted stacks, DescribeStackResource returns resource information for up to 90 days after the stack has been deleted.

Parameters:stack_name_or_id (string) – The name or the unique identifier associated with the stack.

Default: There is no default value.

Parameters:logical_resource_id (string) – The logical name of the resource as specified in the template.

Default: There is no default value.

describe_stack_resources(stack_name_or_id=None, logical_resource_id=None, physical_resource_id=None)

Returns AWS resource descriptions for running and deleted stacks. If StackName is specified, all the associated resources that are part of the stack are returned. If PhysicalResourceId is specified, the associated resources of the stack that the resource belongs to are returned. Only the first 100 resources will be returned. If your stack has more resources than this, you should use ListStackResources instead. For deleted stacks, DescribeStackResources returns resource information for up to 90 days after the stack has been deleted.

You must specify either StackName or PhysicalResourceId, but not both. In addition, you can specify LogicalResourceId to filter the returned result. For more information about resources, the LogicalResourceId and PhysicalResourceId, go to the `AWS CloudFormation User Guide`_. A ValidationError is returned if you specify both StackName and PhysicalResourceId in the same request.

Parameters:stack_name_or_id (string) – The name or the unique identifier associated with the stack.
Required: Conditional. If you do not specify StackName, you must
specify PhysicalResourceId.

Default: There is no default value.

Parameters:logical_resource_id (string) – The logical name of the resource as specified in the template.

Default: There is no default value.

Parameters:physical_resource_id (string) – The name or unique identifier that corresponds to a physical instance ID of a resource supported by AWS CloudFormation.
For example, for an Amazon Elastic Compute Cloud (EC2) instance,
PhysicalResourceId corresponds to the InstanceId. You can pass the EC2 InstanceId to DescribeStackResources to find which stack the instance belongs to and what other resources are part of the stack.
Required: Conditional. If you do not specify PhysicalResourceId, you
must specify StackName.

Default: There is no default value.

describe_stacks(stack_name_or_id=None, next_token=None)

Returns the description for the specified stack; if no stack name was specified, then it returns the description for all the stacks created.

Parameters:stack_name_or_id (string) – The name or the unique identifier associated with the stack.

Default: There is no default value.

Parameters:next_token (string) – String that identifies the start of the next list of stacks, if there is one.
encode_bool(v)
estimate_template_cost(template_body=None, template_url=None, parameters=None)

Returns the estimated monthly cost of a template. The return value is an AWS Simple Monthly Calculator URL with a query string that describes the resources required to run the template.

Parameters:template_body (string) – Structure containing the template body. (For more information, go to `Template Anatomy`_ in the AWS CloudFormation User Guide.)
Conditional: You must pass TemplateBody or TemplateURL. If both are
passed, only TemplateBody is used.
Parameters: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. For more information, go to `Template Anatomy`_ in the AWS CloudFormation User Guide.
Conditional: You must pass TemplateURL or TemplateBody. If both are
passed, only TemplateBody is used.
Parameters:parameters (list) – A list of key/value tuples that specify input parameters for the template.
Return type:string
Returns:URL to pre-filled cost calculator
get_stack_policy(stack_name_or_id)

Returns the stack policy for a specified stack. If a stack doesn’t have a policy, a null value is returned.

Parameters:stack_name_or_id (string) – The name or stack ID that is associated with the stack whose policy you want to get.
Return type:string
Returns:The policy JSON document
get_template(stack_name_or_id)

Returns the template body for a specified stack. You can get the template for running or deleted stacks.

For deleted stacks, GetTemplate returns the template for up to 90 days after the stack has been deleted. If the template does not exist, a ValidationError is returned.

Parameters:stack_name_or_id (string) – The name or the unique identifier associated with the stack, which are not always interchangeable:
  • Running stacks: You can specify either the stack’s name or its unique
    stack ID.
  • Deleted stacks: You must specify the unique stack ID.

Default: There is no default value.

list_stack_resources(stack_name_or_id, next_token=None)

Returns descriptions of all resources of the specified stack.

For deleted stacks, ListStackResources returns resource information for up to 90 days after the stack has been deleted.

Parameters:stack_name_or_id (string) – The name or the unique identifier associated with the stack, which are not always interchangeable:
  • Running stacks: You can specify either the stack’s name or its unique
    stack ID.
  • Deleted stacks: You must specify the unique stack ID.

Default: There is no default value.

Parameters:next_token (string) – String that identifies the start of the next list of stack resource summaries, if there is one.

Default: There is no default value.

list_stacks(stack_status_filters=None, next_token=None)

Returns the summary information for stacks whose status matches the specified StackStatusFilter. Summary information for stacks that have been deleted is kept for 90 days after the stack is deleted. If no StackStatusFilter is specified, summary information for all stacks is returned (including existing stacks and stacks that have been deleted).

Parameters:next_token (string) – String that identifies the start of the next list of stacks, if there is one.

Default: There is no default value.

Parameters:stack_status_filter (list) – Stack status to use as a filter. Specify one or more stack status codes to list only stacks with the specified status codes. For a complete list of stack status codes, see the StackStatus parameter of the Stack data type.
set_stack_policy(stack_name_or_id, stack_policy_body=None, stack_policy_url=None)

Sets a stack policy for a specified stack.

Parameters:
  • stack_name_or_id (string) – The name or stack ID that you want to associate a policy with.
  • stack_policy_body (string) – Structure containing the stack policy body. (For more information, go to ` Prevent Updates to Stack Resources`_ in the AWS CloudFormation User Guide.)
You must pass StackPolicyBody or StackPolicyURL. If both are
passed, only StackPolicyBody is used.
Parameters:stack_policy_url (string) – Location of a file containing the stack policy. The URL must point to a policy (max size: 16KB) located in an S3 bucket in the same region as the stack. You must pass StackPolicyBody or StackPolicyURL. If both are passed, only StackPolicyBody is used.
update_stack(stack_name, template_body=None, template_url=None, parameters=None, notification_arns=None, disable_rollback=False, timeout_in_minutes=None, capabilities=None, tags=None, use_previous_template=None, stack_policy_during_update_body=None, stack_policy_during_update_url=None, stack_policy_body=None, stack_policy_url=None)

Updates a stack as specified in the template. After the call completes successfully, the stack update starts. You can check the status of the stack via the DescribeStacks action.

**Note: **You cannot update `AWS::S3::Bucket`_ resources, for example, to add or modify tags.

To get a copy of the template for an existing stack, you can use the GetTemplate action.

Tags that were associated with this stack during creation time will still be associated with the stack after an UpdateStack operation.

For more information about creating an update template, updating a stack, and monitoring the progress of the update, see `Updating a Stack`_.

Parameters:stack_name (string) –

The name or stack ID of the stack to update.

Must contain only alphanumeric characters (case sensitive) and start
with an alpha character. Maximum length of the name is 255 characters.
Parameters:template_body (string) – Structure containing the template body. (For more information, go to `Template Anatomy`_ in the AWS CloudFormation User Guide.)
Conditional: You must pass either UsePreviousTemplate or one of
TemplateBody or TemplateUrl. If both TemplateBody and TemplateUrl are passed, only TemplateBody is used.
Parameters:template_url (string) – Location of file containing the template body. The URL must point to a template (max size: 307,200 bytes) located in an S3 bucket in the same region as the stack. For more information, go to the `Template Anatomy`_ in the AWS CloudFormation User Guide.
Conditional: You must pass either UsePreviousTemplate or one of
TemplateBody or TemplateUrl. If both TemplateBody and TemplateUrl are passed, only TemplateBody is used. TemplateBody.
Parameters:use_previous_template (boolean) – Set to True to use the previous template instead of uploading a new one via TemplateBody or TemplateURL.
Conditional: You must pass either UsePreviousTemplate or one of
TemplateBody or TemplateUrl.
Parameters:
  • parameters (list) – A list of key/value tuples that specify input parameters for the stack. A 3-tuple (key, value, bool) may be used to specify the UsePreviousValue option.
  • notification_arns (list) – The Simple Notification Service (SNS) topic ARNs to publish stack related events. You can find your SNS topic ARNs using the `SNS console`_ or your Command Line Interface (CLI).
  • 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; if DisableRollback is not set or is set to False, the stack will be rolled back.
  • capabilities (list) – The list of capabilities you want to allow in the stack. Currently, the only valid capability is ‘CAPABILITY_IAM’.
  • tags (dict) – A set of user-defined Tags to associate with this stack, represented by key/value pairs. Tags defined for the stack are propagated to EC2 resources that are created as part of the stack. A maximum number of 10 tags can be specified.
  • 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. For more information, go to `Template Anatomy`_ in the AWS CloudFormation User Guide.
Conditional: You must pass TemplateURL or TemplateBody. If both are
passed, only TemplateBody is used.
Parameters:stack_policy_during_update_body (string) – Structure containing the temporary overriding stack policy body. If you pass StackPolicyDuringUpdateBody and StackPolicyDuringUpdateURL, only StackPolicyDuringUpdateBody is used.
If you want to update protected resources, specify a temporary
overriding stack policy during this update. If you do not specify a stack policy, the current policy that associated with the stack will be used.
Parameters:stack_policy_during_update_url (string) – Location of a file containing the temporary overriding stack policy. The URL must point to a policy (max size: 16KB) located in an S3 bucket in the same region as the stack. If you pass StackPolicyDuringUpdateBody and StackPolicyDuringUpdateURL, only StackPolicyDuringUpdateBody is used.
If you want to update protected resources, specify a temporary
overriding stack policy during this update. If you do not specify a stack policy, the current policy that is associated with the stack will be used.
Return type:string
Returns:The unique Stack ID.
valid_states = ('CREATE_IN_PROGRESS', 'CREATE_FAILED', 'CREATE_COMPLETE', 'ROLLBACK_IN_PROGRESS', 'ROLLBACK_FAILED', 'ROLLBACK_COMPLETE', 'DELETE_IN_PROGRESS', 'DELETE_FAILED', 'DELETE_COMPLETE', 'UPDATE_IN_PROGRESS', 'UPDATE_COMPLETE_CLEANUP_IN_PROGRESS', 'UPDATE_COMPLETE', 'UPDATE_ROLLBACK_IN_PROGRESS', 'UPDATE_ROLLBACK_FAILED', 'UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS', 'UPDATE_ROLLBACK_COMPLETE')
validate_template(template_body=None, template_url=None)

Validates a specified template.

Parameters:template_body (string) – String containing the template body. (For more information, go to `Template Anatomy`_ in the AWS CloudFormation User Guide.)
Conditional: You must pass TemplateURL or TemplateBody. If both are
passed, only TemplateBody is used.
Parameters:template_url (string) – Location of file containing the template body. The URL must point to a template (max size: 307,200 bytes) located in an S3 bucket in the same region as the stack. For more information, go to `Template Anatomy`_ in the AWS CloudFormation User Guide.
Conditional: You must pass TemplateURL or TemplateBody. If both are
passed, only TemplateBody is used.

boto.cloudformation.stack

class boto.cloudformation.stack.Capability(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.cloudformation.stack.NotificationARN(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.cloudformation.stack.Output(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.cloudformation.stack.Parameter(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.cloudformation.stack.Stack(connection=None)
delete()
describe_events(next_token=None)
describe_resource(logical_resource_id)
describe_resources(logical_resource_id=None, physical_resource_id=None)
endElement(name, value, connection)
get_policy()

Returns the stack policy for this stack. If it has no policy then, a null value is returned.

get_template()
list_resources(next_token=None)
set_policy(stack_policy_body=None, stack_policy_url=None)

Sets a stack policy for this stack.

Parameters:stack_policy_body (string) – Structure containing the stack policy body. (For more information, go to ` Prevent Updates to Stack Resources`_ in the AWS CloudFormation User Guide.)
You must pass StackPolicyBody or StackPolicyURL. If both are
passed, only StackPolicyBody is used.
Parameters:stack_policy_url (string) – Location of a file containing the stack policy. The URL must point to a policy (max size: 16KB) located in an S3 bucket in the same region as the stack. You must pass StackPolicyBody or StackPolicyURL. If both are passed, only StackPolicyBody is used.
stack_name_reason
startElement(name, attrs, connection)
update()
class boto.cloudformation.stack.StackEvent(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)
valid_states = ('CREATE_IN_PROGRESS', 'CREATE_FAILED', 'CREATE_COMPLETE', 'DELETE_IN_PROGRESS', 'DELETE_FAILED', 'DELETE_COMPLETE')
class boto.cloudformation.stack.StackResource(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.cloudformation.stack.StackResourceSummary(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.cloudformation.stack.StackSummary(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.cloudformation.stack.Tag(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)

boto.cloudformation.template

class boto.cloudformation.template.Template(connection=None)
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.cloudformation.template.TemplateParameter(parent)
endElement(name, value, connection)
startElement(name, attrs, connection)