aws_codeseeder.services.cfn

Module Contents

Functions

deploy_template(stack_name: str, filename: str, seedkit_tag: Optional[str] = None, s3_bucket: Optional[str] = None, parameters: Optional[Dict[str, str]] = None, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) → None

Deploy a local CloudFormation Template

destroy_stack(stack_name: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) → None

Destroy the CloudFormation Stack

does_stack_exist(stack_name: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) → Tuple[bool, Dict[str, str]]

Checks for existence of a CloudFormation Stack while also returning Stack Outputs if it does exist

get_stack_name(seedkit_name: str) → str

Helper function to calculate the name of a CloudFormation Stack for a given Seedkit

get_stack_status(stack_name: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) → str

Retrieve the status of a CloudFormation Stack

Attributes

CHANGESET_PREFIX

aws_codeseeder.services.cfn.CHANGESET_PREFIX = aws-codeseeder-
aws_codeseeder.services.cfn.deploy_template(stack_name: str, filename: str, seedkit_tag: Optional[str] = None, s3_bucket: Optional[str] = None, parameters: Optional[Dict[str, str]] = None, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) None

Deploy a local CloudFormation Template

The function will automatically calculate a ChangeSet if the Stack already exists and update accordingly. If the local template file is too large, it will be uploaded to the optional s3_buckeet and deployed from there.

Parameters
  • stack_name (str) – Name of the CloudFormation Stack to deploy

  • filename (str) – Name of the local CloudFormation template file

  • seedkit_tag (Optional[str], optional) – Name of the Seedkit to Tag resources in the Stack with, by default None

  • s3_bucket (Optional[str], optional) – S3 Bucket to upload the template file to if it is too large (> 51200), by default None

  • parameters (Optional[Dict[str, str]], optional) – Key/Value set of Input Parameters to pass to the CloudFormation stack, by default None

  • session (Optional[Union[Callable[[], Session], Session]], optional) – Optional Session or function returning a Session to use for all boto3 operations, by default None

Raises
  • FileNotFoundError – If the local template file is not found

  • ValueError – If the S3 Bucket is not found

aws_codeseeder.services.cfn.destroy_stack(stack_name: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) None

Destroy the CloudFormation Stack

Parameters
  • stack_name (str) – Name of the CloudFormation Stack to destroy

  • session (Optional[Union[Callable[[], Session], Session]], optional) – Optional Session or function returning a Session to use for all boto3 operations, by default None

aws_codeseeder.services.cfn.does_stack_exist(stack_name: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) Tuple[bool, Dict[str, str]]

Checks for existence of a CloudFormation Stack while also returning Stack Outputs if it does exist

Parameters
  • stack_name (str) – Name of the CloudFormation Stack to query

  • session (Optional[Union[Callable[[], Session], Session]], optional) – Optional Session or function returning a Session to use for all boto3 operations, by default None

Returns

Tuple2 with a boolean indicating Stack existence and a dict of any Stack Outputs

Return type

Tuple[bool, Dict[str, str]]

aws_codeseeder.services.cfn.get_stack_name(seedkit_name: str) str

Helper function to calculate the name of a CloudFormation Stack for a given Seedkit

Parameters

seedkit_name (str) – Name of the Seedkit

Returns

Name of the Stack Name associated with the Seedkit

Return type

str

aws_codeseeder.services.cfn.get_stack_status(stack_name: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) str

Retrieve the status of a CloudFormation Stack

Parameters
  • stack_name (str) – Name of the CloudFormation Stack to query

  • session (Optional[Union[Callable[[], Session], Session]], optional) – Optional Session or function returning a Session to use for all boto3 operations, by default None

Returns

The status of the CloudFormation Stack, see official boto3 documentation for potential status values: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudformation.html#CloudFormation.Client.describe_stacks

Return type

str

Raises

ValueError – If the Stack is not found