StackInstances

class aws_cdk.aws_codepipeline_actions.StackInstances

Bases: object

Where Stack Instances will be created from the StackSet.

ExampleMetadata

infused

Example:

# pipeline: codepipeline.Pipeline
# source_output: codepipeline.Artifact


pipeline.add_stage(
    stage_name="DeployStackSets",
    actions=[
        # First, update the StackSet itself with the newest template
        codepipeline_actions.CloudFormationDeployStackSetAction(
            action_name="UpdateStackSet",
            run_order=1,
            stack_set_name="MyStackSet",
            template=codepipeline_actions.StackSetTemplate.from_artifact_path(source_output.at_path("template.yaml")),

            # Change this to 'StackSetDeploymentModel.organizations()' if you want to deploy to OUs
            deployment_model=codepipeline_actions.StackSetDeploymentModel.self_managed(),
            # This deploys to a set of accounts
            stack_instances=codepipeline_actions.StackInstances.in_accounts(["111111111111"], ["us-east-1", "eu-west-1"])
        ),

        # Afterwards, update/create additional instances in other accounts
        codepipeline_actions.CloudFormationDeployStackInstancesAction(
            action_name="AddMoreInstances",
            run_order=2,
            stack_set_name="MyStackSet",
            stack_instances=codepipeline_actions.StackInstances.in_accounts(["222222222222", "333333333333"], ["us-east-1", "eu-west-1"])
        )
    ]
)

Static Methods

classmethod from_artifact_path(artifact_path, regions)

Create stack instances in a set of accounts or organizational units taken from the pipeline artifacts, and a set of regions The file must be a JSON file containing a list of strings.

For example:

[
   "111111111111",
   "222222222222",
   "333333333333"
]

Stack Instances will be created in every combination of region and account, or region and Organizational Units (OUs).

If this is set of Organizational Units, you must have selected StackSetDeploymentModel.organizations() as deployment model.

Parameters
  • artifact_path (ArtifactPath) –

  • regions (Sequence[str]) –

Return type

StackInstances

classmethod in_accounts(accounts, regions)

Create stack instances in a set of accounts and regions passed as literal lists.

Stack Instances will be created in every combination of region and account. .. epigraph:

NOTE: ``StackInstances.inAccounts()`` and ``StackInstances.inOrganizationalUnits()``
have exactly the same behavior, and you can use them interchangeably if you want.
The only difference between them is that your code clearly indicates what entity
it's working with.
Parameters
  • accounts (Sequence[str]) –

  • regions (Sequence[str]) –

Return type

StackInstances

classmethod in_organizational_units(ous, regions)

Create stack instances in all accounts in a set of Organizational Units (OUs) and regions passed as literal lists.

If you want to deploy to Organization Units, you must choose have created the StackSet with deploymentModel: DeploymentModel.organizations().

Stack Instances will be created in every combination of region and account. .. epigraph:

NOTE: ``StackInstances.inAccounts()`` and ``StackInstances.inOrganizationalUnits()``
have exactly the same behavior, and you can use them interchangeably if you want.
The only difference between them is that your code clearly indicates what entity
it's working with.
Parameters
  • ous (Sequence[str]) –

  • regions (Sequence[str]) –

Return type

StackInstances