cdk-stacksets


Namecdk-stacksets JSON
Version 0.0.150 PyPI version JSON
download
home_pagehttps://github.com/cdklabs/cdk-stacksets.git
Summarycdk-stacksets
upload_time2024-02-06 18:36:14
maintainer
docs_urlNone
authorAmazon Web Services<aws-cdk-dev@amazon.com>
requires_python~=3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CDK StackSets Construct Library

<!--BEGIN STABILITY BANNER-->---


![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)

> The APIs of higher level constructs in this module are experimental and under active development.
> They are subject to non-backward compatible changes or removal in any future version. These are
> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be
> announced in the release notes. This means that while you may use them, you may need to update
> your source code when upgrading to a newer version of this package.

---
<!--END STABILITY BANNER-->

This construct library allows you to define AWS CloudFormation StackSets.

```python
stack = Stack()
stack_set_stack = StackSetStack(stack, "MyStackSet")

StackSet(stack, "StackSet",
    target=StackSetTarget.from_accounts(
        regions=["us-east-1"],
        accounts=["11111111111"],
        parameter_overrides={
            "SomeParam": "overrideValue"
        }
    ),
    template=StackSetTemplate.from_stack_set_stack(stack_set_stack)
)
```

## Installing

### TypeScript/JavaScript

```bash
npm install cdk-stacksets
```

### Python

```bash
pip install cdk-stacksets
```

### Java

```xml
// add this to your pom.xml
<dependency>
    <groupId>io.github.cdklabs</groupId>
    <artifactId>cdk-stacksets</artifactId>
    <version>0.0.0</version> // replace with version
</dependency>
```

### .NET

```bash
dotnet add package CdklabsCdkStacksets --version X.X.X
```

### Go

```bash
go get cdk-stacksets-go
```

## Creating a StackSet Stack

StackSets allow you to deploy a single CloudFormation template across multiple AWS accounts and regions.
Typically when creating a CDK Stack that will be deployed across multiple environments, the CDK will
synthesize separate Stack templates for each environment (account/region combination). Because of the
way that StackSets work, StackSet Stacks behave differently. For Stacks that will be deployed via StackSets
a single Stack is defined and synthesized. Any environmental differences must be encoded using Parameters.

A special class was created to handle the uniqueness of the StackSet Stack.
You declare a `StackSetStack` the same way that you declare a normal `Stack`, but there
are a couple of differences. `StackSetStack`s have a couple of special requirements/limitations when
compared to Stacks.

*Requirements*

* Must be created in the scope of a `Stack`
* Must be environment agnostic

*Limitations*

* Does not support Docker container assets

Once you create a `StackSetStack` you can create resources within the stack.

```python
stack = Stack()
stack_set_stack = StackSetStack(stack, "StackSet")

iam.Role(stack_set_stack, "MyRole",
    assumed_by=iam.ServicePrincipal("myservice.amazonaws.com")
)
```

Or

```python
class MyStackSet(StackSetStack):
    def __init__(self, scope, id):
        super().__init__(scope, id)

        iam.Role(self, "MyRole",
            assumed_by=iam.ServicePrincipal("myservice.amazonaws.com")
        )
```

## Creating a StackSet

AWS CloudFormation StackSets enable you to create, update, or delete stacks across multiple accounts and AWS Regions
with a single operation. Using an administrator account, you define and manage an AWS CloudFormation template, and use
the template as the basis for provisioning stacks into selected target accounts across specific AWS Regions.

There are two methods for defining *where* the StackSet should be deployed. You can either define individual accounts, or
you can define AWS Organizations organizational units.

### Deploying to individual accounts

Deploying to individual accounts requires you to specify the account ids. If you want to later deploy to additional accounts,
or remove the stackset from accounts, this has to be done by adding/removing the account id from the list.

```python
stack = Stack()
stack_set_stack = StackSetStack(stack, "MyStackSet")

StackSet(stack, "StackSet",
    target=StackSetTarget.from_accounts(
        regions=["us-east-1"],
        accounts=["11111111111"]
    ),
    template=StackSetTemplate.from_stack_set_stack(stack_set_stack)
)
```

### Deploying to organizational units

AWS Organizations is an AWS service that enables you to centrally manage and govern multiple accounts.
AWS Organizations allows you to define organizational units (OUs) which are logical groupings of AWS accounts.
OUs enable you to organize your accounts into a hierarchy and make it easier for you to apply management controls.
For a deep dive on OU best practices you can read the [Best Practices for Organizational Units with AWS Organizations](https://aws.amazon.com/blogs/mt/best-practices-for-organizational-units-with-aws-organizations/) blog post.

You can either specify the organization itself, or individual OUs. By default the StackSet will be deployed
to all AWS accounts that are part of the OU. If the OU is nested it will also deploy to all accounts
that are part of any nested OUs.

For example, given the following org hierarchy

```mermaid
graph TD
  root-->ou-1;
  root-->ou-2;
  ou-1-->ou-3;
  ou-1-->ou-4;
  ou-3-->account-1;
  ou-3-->account-2;
  ou-4-->account-4;
  ou-2-->account-3;
  ou-2-->account-5;
```

You could deploy to all AWS accounts under OUs `ou-1`, `ou-3`, `ou-4` by specifying the following:

```python
stack = Stack()
stack_set_stack = StackSetStack(stack, "MyStackSet")

StackSet(stack, "StackSet",
    target=StackSetTarget.from_organizational_units(
        regions=["us-east-1"],
        organizational_units=["ou-1"]
    ),
    template=StackSetTemplate.from_stack_set_stack(stack_set_stack)
)
```

This would deploy the StackSet to `account-1`, `account-2`, `account-4`.

If there are specific AWS accounts that are part of the specified OU hierarchy that you would like
to exclude, this can be done by specifying `excludeAccounts`.

```python
stack = Stack()
stack_set_stack = StackSetStack(stack, "MyStackSet")

StackSet(stack, "StackSet",
    target=StackSetTarget.from_organizational_units(
        regions=["us-east-1"],
        organizational_units=["ou-1"],
        exclude_accounts=["account-2"]
    ),
    template=StackSetTemplate.from_stack_set_stack(stack_set_stack)
)
```

This would deploy only to `account-1` & `account-4`, and would exclude `account-2`.

Sometimes you might have individual accounts that you would like to deploy the StackSet to, but
you do not want to include the entire OU. To do that you can specify `additionalAccounts`.

```python
stack = Stack()
stack_set_stack = StackSetStack(stack, "MyStackSet")

StackSet(stack, "StackSet",
    target=StackSetTarget.from_organizational_units(
        regions=["us-east-1"],
        organizational_units=["ou-1"],
        additional_accounts=["account-5"]
    ),
    template=StackSetTemplate.from_stack_set_stack(stack_set_stack)
)
```

This would deploy the StackSet to `account-1`, `account-2`, `account-4` & `account-5`.

### StackSet permissions

There are two modes for managing StackSet permissions (i.e. *where* StackSets can deploy & *what* resources they can create).
A StackSet can either be `Service Managed` or `Self Managed`.

You can control this through the `deploymentType` parameter.

#### Service Managed

When a StackSet is service managed, the permissions are managed by AWS Organizations. This allows the StackSet to deploy the Stack to *any*
account within the organization. In addition, the StackSet will be able to create *any* type of resource.

```python
stack = Stack()
stack_set_stack = StackSetStack(stack, "MyStackSet")

StackSet(stack, "StackSet",
    target=StackSetTarget.from_organizational_units(
        regions=["us-east-1"],
        organizational_units=["ou-1"]
    ),
    deployment_type=DeploymentType.service_managed(),
    template=StackSetTemplate.from_stack_set_stack(stack_set_stack)
)
```

When you specify `serviceManaged` deployment type, automatic deployments are enabled by default.
Automatic deployments allow the StackSet to be automatically deployed to or deleted from
AWS accounts when they are added or removed from the specified organizational units.

### Using File Assets

You can use the StackSet's parent stack to facilitate file assets. Behind the scenes,
this is accomplished using the `BucketDeployment` construct from the
`aws_s3_deployment` module. You need to provide a list of buckets outside the scope of the CDK
managed asset buckets and ensure you have permissions for the target accounts to pull
the artifacts from the supplied bucket(s).

As a basic example, if using a `serviceManaged` deployment, you just need to give read
access to the Organization. You can create the asset bucket in the parent stack, or another
stack in the same app and pass the object as a prop. Or, import an existing bucket as needed.

If creating in the parent or sibling stack you could create and export similar to this:

```python
bucket = s3.Bucket(self, "Assets",
    bucket_name="prefix-us-east-1"
)

bucket.add_to_resource_policy(
    iam.PolicyStatement(
        actions=["s3:Get*", "s3:List*"],
        resources=[bucket.arn_for_objects("*"), bucket.bucket_arn],
        principals=[iam.OrganizationPrincipal("o-xyz")]
    ))
```

Then pass as a prop to the StackSet stack:

```python
# bucket: s3.Bucket

stack = Stack()
stack_set_stack = StackSetStack(stack, "MyStackSet",
    asset_buckets=[bucket],
    asset_bucket_prefix="prefix"
)
```

To faciliate multi region deployments, there is an assetBucketPrefix property. This
gets added to the region the Stack Set is deployed to. The stack synthesis for
the Stack Set would look for a bucket named `prefix-{Region}` in the example
above. `{Region}` is whatever region you are deploying the Stack Set to as
defined in your target property of the StackSet. You will need to ensure the
bucket name is correct based on what was previously created and then passed in.

You can use self-managed StackSet deployments with file assets too but will
need to ensure all target accounts roles will have access to the central asset
bucket you pass as the property.

## Deploying StackSets using CDK Pipelines

You can also deploy StackSets using [CDK Pipelines](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines-readme.html)

Below is an example of a Pipeline that deploys from a central account. It also
defines separate stages for each "environment" so that you can first test out
the stackset in pre-prod environments.

This would be an automated way of deploying the bootstrap stack described in
[this blog
post](https://aws.amazon.com/blogs/mt/bootstrapping-multiple-aws-accounts-for-aws-cdk-using-cloudformation-stacksets/).

```python
# app: App


class BootstrapStage(Stage):
    def __init__(self, scope, id, *, initialBootstrapTarget, stacksetName=None, env=None, outdir=None, stageName=None, permissionsBoundary=None, policyValidationBeta1=None):
        super().__init__(scope, id, initialBootstrapTarget=initialBootstrapTarget, stacksetName=stacksetName, env=env, outdir=outdir, stageName=stageName, permissionsBoundary=permissionsBoundary, policyValidationBeta1=policyValidationBeta1)

        stack = Stack(self, "BootstrapStackSet")

        bootstrap = Bootstrap(stack, "CDKToolkit")

        stack_set = StackSet(stack, "StackSet",
            template=StackSetTemplate.from_stack_set_stack(bootstrap),
            target=initial_bootstrap_target,
            capabilities=[Capability.NAMED_IAM],
            managed_execution=True,
            stack_set_name=stackset_name,
            deployment_type=DeploymentType.service_managed(
                delegated_admin=True,
                auto_deploy_enabled=True,
                auto_deploy_retain_stacks=False
            ),
            operation_preferences=OperationPreferences(
                region_concurrency_type=RegionConcurrencyType.PARALLEL,
                max_concurrent_percentage=100,
                failure_tolerance_percentage=99
            )
        )

pipeline = pipelines.CodePipeline(self, "BootstrapPipeline",
    synth=pipelines.ShellStep("Synth",
        commands=["yarn install --frozen-lockfile", "npx cdk synth"
        ],
        input=pipelines.CodePipelineSource.connection("myorg/myrepo", "main",
            connection_arn="arn:aws:codestar-connections:us-east-2:111111111111:connection/ca65d487-ca6e-41cc-aab2-645db37fdb2b"
        )
    ),
    self_mutation=True
)

regions = ["us-east-1", "us-east-2", "us-west-2", "eu-west-2", "eu-west-1", "ap-south-1", "ap-southeast-1"
]

pipeline.add_stage(
    BootstrapStage(app, "DevBootstrap",
        env=Environment(
            region="us-east-1",
            account="111111111111"
        ),
        stackset_name="CDKToolkit-dev",
        initial_bootstrap_target=StackSetTarget.from_organizational_units(
            regions=regions,
            organizational_units=["ou-hrza-ar333427"]
        )
    ))

pipeline.add_stage(
    BootstrapStage(app, "ProdBootstrap",
        env=Environment(
            region="us-east-1",
            account="111111111111"
        ),
        stackset_name="CDKToolkit-prd",
        initial_bootstrap_target=StackSetTarget.from_organizational_units(
            regions=regions,
            organizational_units=["ou-hrza-bb999427", "ou-hraa-ar111127"]
        )
    ))
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cdklabs/cdk-stacksets.git",
    "name": "cdk-stacksets",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "~=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "Amazon Web Services<aws-cdk-dev@amazon.com>",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/1f/36/71946a15bc73a552df14d3371b11e90490f9a15872058e5bd8a52195b9df/cdk-stacksets-0.0.150.tar.gz",
    "platform": null,
    "description": "# CDK StackSets Construct Library\n\n<!--BEGIN STABILITY BANNER-->---\n\n\n![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)\n\n> The APIs of higher level constructs in this module are experimental and under active development.\n> They are subject to non-backward compatible changes or removal in any future version. These are\n> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be\n> announced in the release notes. This means that while you may use them, you may need to update\n> your source code when upgrading to a newer version of this package.\n\n---\n<!--END STABILITY BANNER-->\n\nThis construct library allows you to define AWS CloudFormation StackSets.\n\n```python\nstack = Stack()\nstack_set_stack = StackSetStack(stack, \"MyStackSet\")\n\nStackSet(stack, \"StackSet\",\n    target=StackSetTarget.from_accounts(\n        regions=[\"us-east-1\"],\n        accounts=[\"11111111111\"],\n        parameter_overrides={\n            \"SomeParam\": \"overrideValue\"\n        }\n    ),\n    template=StackSetTemplate.from_stack_set_stack(stack_set_stack)\n)\n```\n\n## Installing\n\n### TypeScript/JavaScript\n\n```bash\nnpm install cdk-stacksets\n```\n\n### Python\n\n```bash\npip install cdk-stacksets\n```\n\n### Java\n\n```xml\n// add this to your pom.xml\n<dependency>\n    <groupId>io.github.cdklabs</groupId>\n    <artifactId>cdk-stacksets</artifactId>\n    <version>0.0.0</version> // replace with version\n</dependency>\n```\n\n### .NET\n\n```bash\ndotnet add package CdklabsCdkStacksets --version X.X.X\n```\n\n### Go\n\n```bash\ngo get cdk-stacksets-go\n```\n\n## Creating a StackSet Stack\n\nStackSets allow you to deploy a single CloudFormation template across multiple AWS accounts and regions.\nTypically when creating a CDK Stack that will be deployed across multiple environments, the CDK will\nsynthesize separate Stack templates for each environment (account/region combination). Because of the\nway that StackSets work, StackSet Stacks behave differently. For Stacks that will be deployed via StackSets\na single Stack is defined and synthesized. Any environmental differences must be encoded using Parameters.\n\nA special class was created to handle the uniqueness of the StackSet Stack.\nYou declare a `StackSetStack` the same way that you declare a normal `Stack`, but there\nare a couple of differences. `StackSetStack`s have a couple of special requirements/limitations when\ncompared to Stacks.\n\n*Requirements*\n\n* Must be created in the scope of a `Stack`\n* Must be environment agnostic\n\n*Limitations*\n\n* Does not support Docker container assets\n\nOnce you create a `StackSetStack` you can create resources within the stack.\n\n```python\nstack = Stack()\nstack_set_stack = StackSetStack(stack, \"StackSet\")\n\niam.Role(stack_set_stack, \"MyRole\",\n    assumed_by=iam.ServicePrincipal(\"myservice.amazonaws.com\")\n)\n```\n\nOr\n\n```python\nclass MyStackSet(StackSetStack):\n    def __init__(self, scope, id):\n        super().__init__(scope, id)\n\n        iam.Role(self, \"MyRole\",\n            assumed_by=iam.ServicePrincipal(\"myservice.amazonaws.com\")\n        )\n```\n\n## Creating a StackSet\n\nAWS CloudFormation StackSets enable you to create, update, or delete stacks across multiple accounts and AWS Regions\nwith a single operation. Using an administrator account, you define and manage an AWS CloudFormation template, and use\nthe template as the basis for provisioning stacks into selected target accounts across specific AWS Regions.\n\nThere are two methods for defining *where* the StackSet should be deployed. You can either define individual accounts, or\nyou can define AWS Organizations organizational units.\n\n### Deploying to individual accounts\n\nDeploying to individual accounts requires you to specify the account ids. If you want to later deploy to additional accounts,\nor remove the stackset from accounts, this has to be done by adding/removing the account id from the list.\n\n```python\nstack = Stack()\nstack_set_stack = StackSetStack(stack, \"MyStackSet\")\n\nStackSet(stack, \"StackSet\",\n    target=StackSetTarget.from_accounts(\n        regions=[\"us-east-1\"],\n        accounts=[\"11111111111\"]\n    ),\n    template=StackSetTemplate.from_stack_set_stack(stack_set_stack)\n)\n```\n\n### Deploying to organizational units\n\nAWS Organizations is an AWS service that enables you to centrally manage and govern multiple accounts.\nAWS Organizations allows you to define organizational units (OUs) which are logical groupings of AWS accounts.\nOUs enable you to organize your accounts into a hierarchy and make it easier for you to apply management controls.\nFor a deep dive on OU best practices you can read the [Best Practices for Organizational Units with AWS Organizations](https://aws.amazon.com/blogs/mt/best-practices-for-organizational-units-with-aws-organizations/) blog post.\n\nYou can either specify the organization itself, or individual OUs. By default the StackSet will be deployed\nto all AWS accounts that are part of the OU. If the OU is nested it will also deploy to all accounts\nthat are part of any nested OUs.\n\nFor example, given the following org hierarchy\n\n```mermaid\ngraph TD\n  root-->ou-1;\n  root-->ou-2;\n  ou-1-->ou-3;\n  ou-1-->ou-4;\n  ou-3-->account-1;\n  ou-3-->account-2;\n  ou-4-->account-4;\n  ou-2-->account-3;\n  ou-2-->account-5;\n```\n\nYou could deploy to all AWS accounts under OUs `ou-1`, `ou-3`, `ou-4` by specifying the following:\n\n```python\nstack = Stack()\nstack_set_stack = StackSetStack(stack, \"MyStackSet\")\n\nStackSet(stack, \"StackSet\",\n    target=StackSetTarget.from_organizational_units(\n        regions=[\"us-east-1\"],\n        organizational_units=[\"ou-1\"]\n    ),\n    template=StackSetTemplate.from_stack_set_stack(stack_set_stack)\n)\n```\n\nThis would deploy the StackSet to `account-1`, `account-2`, `account-4`.\n\nIf there are specific AWS accounts that are part of the specified OU hierarchy that you would like\nto exclude, this can be done by specifying `excludeAccounts`.\n\n```python\nstack = Stack()\nstack_set_stack = StackSetStack(stack, \"MyStackSet\")\n\nStackSet(stack, \"StackSet\",\n    target=StackSetTarget.from_organizational_units(\n        regions=[\"us-east-1\"],\n        organizational_units=[\"ou-1\"],\n        exclude_accounts=[\"account-2\"]\n    ),\n    template=StackSetTemplate.from_stack_set_stack(stack_set_stack)\n)\n```\n\nThis would deploy only to `account-1` & `account-4`, and would exclude `account-2`.\n\nSometimes you might have individual accounts that you would like to deploy the StackSet to, but\nyou do not want to include the entire OU. To do that you can specify `additionalAccounts`.\n\n```python\nstack = Stack()\nstack_set_stack = StackSetStack(stack, \"MyStackSet\")\n\nStackSet(stack, \"StackSet\",\n    target=StackSetTarget.from_organizational_units(\n        regions=[\"us-east-1\"],\n        organizational_units=[\"ou-1\"],\n        additional_accounts=[\"account-5\"]\n    ),\n    template=StackSetTemplate.from_stack_set_stack(stack_set_stack)\n)\n```\n\nThis would deploy the StackSet to `account-1`, `account-2`, `account-4` & `account-5`.\n\n### StackSet permissions\n\nThere are two modes for managing StackSet permissions (i.e. *where* StackSets can deploy & *what* resources they can create).\nA StackSet can either be `Service Managed` or `Self Managed`.\n\nYou can control this through the `deploymentType` parameter.\n\n#### Service Managed\n\nWhen a StackSet is service managed, the permissions are managed by AWS Organizations. This allows the StackSet to deploy the Stack to *any*\naccount within the organization. In addition, the StackSet will be able to create *any* type of resource.\n\n```python\nstack = Stack()\nstack_set_stack = StackSetStack(stack, \"MyStackSet\")\n\nStackSet(stack, \"StackSet\",\n    target=StackSetTarget.from_organizational_units(\n        regions=[\"us-east-1\"],\n        organizational_units=[\"ou-1\"]\n    ),\n    deployment_type=DeploymentType.service_managed(),\n    template=StackSetTemplate.from_stack_set_stack(stack_set_stack)\n)\n```\n\nWhen you specify `serviceManaged` deployment type, automatic deployments are enabled by default.\nAutomatic deployments allow the StackSet to be automatically deployed to or deleted from\nAWS accounts when they are added or removed from the specified organizational units.\n\n### Using File Assets\n\nYou can use the StackSet's parent stack to facilitate file assets. Behind the scenes,\nthis is accomplished using the `BucketDeployment` construct from the\n`aws_s3_deployment` module. You need to provide a list of buckets outside the scope of the CDK\nmanaged asset buckets and ensure you have permissions for the target accounts to pull\nthe artifacts from the supplied bucket(s).\n\nAs a basic example, if using a `serviceManaged` deployment, you just need to give read\naccess to the Organization. You can create the asset bucket in the parent stack, or another\nstack in the same app and pass the object as a prop. Or, import an existing bucket as needed.\n\nIf creating in the parent or sibling stack you could create and export similar to this:\n\n```python\nbucket = s3.Bucket(self, \"Assets\",\n    bucket_name=\"prefix-us-east-1\"\n)\n\nbucket.add_to_resource_policy(\n    iam.PolicyStatement(\n        actions=[\"s3:Get*\", \"s3:List*\"],\n        resources=[bucket.arn_for_objects(\"*\"), bucket.bucket_arn],\n        principals=[iam.OrganizationPrincipal(\"o-xyz\")]\n    ))\n```\n\nThen pass as a prop to the StackSet stack:\n\n```python\n# bucket: s3.Bucket\n\nstack = Stack()\nstack_set_stack = StackSetStack(stack, \"MyStackSet\",\n    asset_buckets=[bucket],\n    asset_bucket_prefix=\"prefix\"\n)\n```\n\nTo faciliate multi region deployments, there is an assetBucketPrefix property. This\ngets added to the region the Stack Set is deployed to. The stack synthesis for\nthe Stack Set would look for a bucket named `prefix-{Region}` in the example\nabove. `{Region}` is whatever region you are deploying the Stack Set to as\ndefined in your target property of the StackSet. You will need to ensure the\nbucket name is correct based on what was previously created and then passed in.\n\nYou can use self-managed StackSet deployments with file assets too but will\nneed to ensure all target accounts roles will have access to the central asset\nbucket you pass as the property.\n\n## Deploying StackSets using CDK Pipelines\n\nYou can also deploy StackSets using [CDK Pipelines](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines-readme.html)\n\nBelow is an example of a Pipeline that deploys from a central account. It also\ndefines separate stages for each \"environment\" so that you can first test out\nthe stackset in pre-prod environments.\n\nThis would be an automated way of deploying the bootstrap stack described in\n[this blog\npost](https://aws.amazon.com/blogs/mt/bootstrapping-multiple-aws-accounts-for-aws-cdk-using-cloudformation-stacksets/).\n\n```python\n# app: App\n\n\nclass BootstrapStage(Stage):\n    def __init__(self, scope, id, *, initialBootstrapTarget, stacksetName=None, env=None, outdir=None, stageName=None, permissionsBoundary=None, policyValidationBeta1=None):\n        super().__init__(scope, id, initialBootstrapTarget=initialBootstrapTarget, stacksetName=stacksetName, env=env, outdir=outdir, stageName=stageName, permissionsBoundary=permissionsBoundary, policyValidationBeta1=policyValidationBeta1)\n\n        stack = Stack(self, \"BootstrapStackSet\")\n\n        bootstrap = Bootstrap(stack, \"CDKToolkit\")\n\n        stack_set = StackSet(stack, \"StackSet\",\n            template=StackSetTemplate.from_stack_set_stack(bootstrap),\n            target=initial_bootstrap_target,\n            capabilities=[Capability.NAMED_IAM],\n            managed_execution=True,\n            stack_set_name=stackset_name,\n            deployment_type=DeploymentType.service_managed(\n                delegated_admin=True,\n                auto_deploy_enabled=True,\n                auto_deploy_retain_stacks=False\n            ),\n            operation_preferences=OperationPreferences(\n                region_concurrency_type=RegionConcurrencyType.PARALLEL,\n                max_concurrent_percentage=100,\n                failure_tolerance_percentage=99\n            )\n        )\n\npipeline = pipelines.CodePipeline(self, \"BootstrapPipeline\",\n    synth=pipelines.ShellStep(\"Synth\",\n        commands=[\"yarn install --frozen-lockfile\", \"npx cdk synth\"\n        ],\n        input=pipelines.CodePipelineSource.connection(\"myorg/myrepo\", \"main\",\n            connection_arn=\"arn:aws:codestar-connections:us-east-2:111111111111:connection/ca65d487-ca6e-41cc-aab2-645db37fdb2b\"\n        )\n    ),\n    self_mutation=True\n)\n\nregions = [\"us-east-1\", \"us-east-2\", \"us-west-2\", \"eu-west-2\", \"eu-west-1\", \"ap-south-1\", \"ap-southeast-1\"\n]\n\npipeline.add_stage(\n    BootstrapStage(app, \"DevBootstrap\",\n        env=Environment(\n            region=\"us-east-1\",\n            account=\"111111111111\"\n        ),\n        stackset_name=\"CDKToolkit-dev\",\n        initial_bootstrap_target=StackSetTarget.from_organizational_units(\n            regions=regions,\n            organizational_units=[\"ou-hrza-ar333427\"]\n        )\n    ))\n\npipeline.add_stage(\n    BootstrapStage(app, \"ProdBootstrap\",\n        env=Environment(\n            region=\"us-east-1\",\n            account=\"111111111111\"\n        ),\n        stackset_name=\"CDKToolkit-prd\",\n        initial_bootstrap_target=StackSetTarget.from_organizational_units(\n            regions=regions,\n            organizational_units=[\"ou-hrza-bb999427\", \"ou-hraa-ar111127\"]\n        )\n    ))\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "cdk-stacksets",
    "version": "0.0.150",
    "project_urls": {
        "Homepage": "https://github.com/cdklabs/cdk-stacksets.git",
        "Source": "https://github.com/cdklabs/cdk-stacksets.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8ce61763066a27ccb3ecbda384391bf68f74f21d30b4d585157c1e689ea52bd2",
                "md5": "416b54a84522c2497ff799a86cbbf884",
                "sha256": "b49769c9fa9cc0ce4fd197e52905552c3831c5c74ede3e9528291bb67f73a346"
            },
            "downloads": -1,
            "filename": "cdk_stacksets-0.0.150-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "416b54a84522c2497ff799a86cbbf884",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.8",
            "size": 105442,
            "upload_time": "2024-02-06T18:36:12",
            "upload_time_iso_8601": "2024-02-06T18:36:12.212716Z",
            "url": "https://files.pythonhosted.org/packages/8c/e6/1763066a27ccb3ecbda384391bf68f74f21d30b4d585157c1e689ea52bd2/cdk_stacksets-0.0.150-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1f3671946a15bc73a552df14d3371b11e90490f9a15872058e5bd8a52195b9df",
                "md5": "5f4de4a9eb8dc2f5db14316505789d20",
                "sha256": "b935c41b8c13af212e56e440aa0d42b1f696a8c825615beee76ab222bb6617dc"
            },
            "downloads": -1,
            "filename": "cdk-stacksets-0.0.150.tar.gz",
            "has_sig": false,
            "md5_digest": "5f4de4a9eb8dc2f5db14316505789d20",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.8",
            "size": 107959,
            "upload_time": "2024-02-06T18:36:14",
            "upload_time_iso_8601": "2024-02-06T18:36:14.963821Z",
            "url": "https://files.pythonhosted.org/packages/1f/36/71946a15bc73a552df14d3371b11e90490f9a15872058e5bd8a52195b9df/cdk-stacksets-0.0.150.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-06 18:36:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cdklabs",
    "github_project": "cdk-stacksets",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cdk-stacksets"
}
        
Elapsed time: 0.19149s