Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

guardian/cdk-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

@guardian/cdk demo!

📹 Screencast of this demo here!

Let's get started.

Tip: each stage below is stored as a corresponding git tag, so you can check those out if you get stuck or want to skip ahead.

1. Prepare your AWS account

@guardian/cdk patterns rely on certain Parameter Store values to be set, for example, an account's primary VPC. To ensure your account meets the prerequisites here, run:

$ npx @guardian/cdk account-readiness --profile [profile] --region eu-west-1

Add any missing parameters as required.

2. Initialise your CDK app

Next, create the core CDK files for your app:

$ npx @guardian/cdk new --app [app] --stack [stack] --yaml-template-location cfn.yaml

Use the --help flag for more info on these and other flags.

3. Diff again your existing stack

Note, this stage will only work for this demo if you have a real Cloudformation stack with the template in cfn.yaml. You can do this quickly in the AWS Console or alternatively, skip this step for now.

Confirm that your CDK template is not materially different from your existing PROD stack by running:

$ cd cdk
$ ./script/diff -s [AWS stack name] -p [profile]

4. Migrate resources into CDK and delete old app

Tip: for higher-risk or more complex applications, you may want to 'dual-stack' for a while to gain confidence in the new infrastructure before deleting the old.

Use GuS3Bucket to recreate the bucket in lib/cdk-demo.ts.

Tip: set GuStack.migratedFromCloudFormation to true and also the existingLogicalId prop on GuS3Bucket to 'adopt' the bucket into CDK without requiring a replacement.

Tip: run a diff again. What changes do you notice, e.g. around bucket security policies?

Tip: another way to see changes is to run the tests. Use yarn test -u to update the snapshot when it changes.

Finally, you can deploy to AWS (if you like) and delete the cfn.yaml file.

About

To illustrate CDK adoption.

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Packages

No packages published