Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduction to CDK #72

Open
phillip-le opened this issue Jul 30, 2024 · 0 comments
Open

Introduction to CDK #72

phillip-le opened this issue Jul 30, 2024 · 0 comments
Labels

Comments

@phillip-le
Copy link
Owner

phillip-le commented Jul 30, 2024

  • What is IaaC
  • What is CloudFormation
  • There are logical IDs which are used by CloudFormation to identify resources uniquely within a stack
  • CDK is a higher level of abstraction over CloudFormation letting you write in your chosen language
  • CDK is composed of constructs which are higher levels of abstraction over base CloudFormation resources
  • Everything is in a CDK app, and then associated with a Stack
  • Snapshot testing to check that nothing has changed
import { Template } from 'aws-cdk-lib/assertions';

const template = Template.fromStack(stack);

const result = JSON.stringify(template).replace(
  /"S3Key":"[^"]+"/g,
  '"S3Key":"[REMOVED]"',
);

expect(JSON.parse(result)).toMatchSnapshot();
  • Prefer to be overly verbose because infrastructure typically doesn't change
  • progress: events is helpful for logging in CI/CD
  • Stateless vs Stateful resources
  • Changing logical IDs will cause resources to be created and destroyed
  • Sometimes you will want to prefer not explicitly setting a name so that CDK can handle cutover of resource creation / deletion under the hood
  • Construct trees
  • If you're using NodeJsFunction, make sure your CI agent has git and bash

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant