AWS CDK Construct Library to manage specific AWS Organization resources
Project description
cdk-library-aws-organization
This CDK library is a WIP and not ready for production use.
Key challenges with Organizations
- Accounts aren't like AWS resources and the removal process isn't a simple delete. Therefore the constructs contained in this library do not have the goal to delete accounts.
- CloudFormation doesn't support Organizations directly so the constructs in this library use CloudFormation custom resources that utilize Python and Boto3
Testing the custom provider code with SAM CLI
- Create a test project that utilizes this library
- Create a test stack
- Synthesize the test stack with
cdk synth --no-staging > template.yml
- Get the function name from the template
- Run
sam local start-lambda -t template.yml
- Run the
handler_tests
python files withpytest
like follows:
LAMBDA_FUNCTION_NAME='<name you noted earlier>' pytest ./handler_tests/<handler>/test.py -rA --capture=sys
- The
test.py
also looks up the root org id to run tests so you'll need to have AWS creds set up to accomodate that behavior. - You can run the provided tests against the real lambda function by getting the deployed function name from AWS and setting the
RUN_LOCALLY
env variable
RUN_LOCALLY='false' LAMBDA_FUNCTION_NAME='<name from AWS>' pytest ./handler_tests/<handler>/test.py -rA --capture=sys
Why can't I move an OU?
Moving OUs isn't supported by Organizations and would cause significant issues with keeping track of OUs in the CDK. Imagine a scenario like below:
-
You have an ou,
OUAdmin
, and it has 2 children,OUChild1 and Account1
, that are also managed by the CDK stack. -
You change the parent of
OUAdmin
toOUFoo
. The CDK would need to take the following actions:-
Create a new
OU
underOUFoo
with the nameOUAdmin
-
Move all of the original
OUAdmin
OU's children to the newOUAdmin
-
Delete the old
OUAdmin
-
Update all physical resource IDs
- It would succeed at moving accounts because physical IDs should not change. Accounting moving between OUs is supported by Organizations
- It would fail at moving any child OUs because they would also be recreated. Resulting in a change to physical resource ID. Because the custom resource can only managed the resource it's currently acting on,
OUAdmin
, any children OUs would be "lost" in this process and ugly to try and manage.
-
The best way to move OUs would be to add additional OUs to your org then move any accounts as needed then proceed to delete the OUs, like so:
- Add new OU resources
- Deploy the stack
- Change account parents
- Deploy the stack
- Remove old OU resources
- Deploy the stack
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for renovosolutions.aws-cdk-aws-organization-0.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e234022543e68a10ade77e4942b8faadb54f8310afe168021cabf18a5b8e9e15 |
|
MD5 | bd8a7e0e66800c9eac3beb18ec18be34 |
|
BLAKE2b-256 | 5cf0b2a9d3f9a7fb434eef21dd8c9e5183d869829980501c8864f4f3b43c2e4e |
Hashes for renovosolutions.aws_cdk_aws_organization-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17230bb4a1e29ff356a4f767716622b825a552499bca3167faf83abcc3da2349 |
|
MD5 | f5eac1986022acca3b374d23104d662f |
|
BLAKE2b-256 | 3902f4d75c72229d11fa05457bbb530d7227d2d3faf7c0c29aaa75b8378743c8 |