# AWS CDK

> Describe your AWS infrastructure in a real programming language instead of YAML.

- Level: Advanced
- Topics: AWS, Cloud
- URL: https://tidbit.legios.com.ar/aws-cdk/
- In Spanish: [AWS CDK](https://tidbit.legios.com.ar/es/aws-cdk/)

**AWS CDK** (Cloud Development Kit) is an infrastructure as code tool where you describe servers, buckets, queues and permissions in TypeScript, Python, Java, C# or Go. Under the hood it does not talk to AWS directly: it **synthesizes** your program into an AWS CloudFormation template, and CloudFormation creates or updates the resources. The two key commands are `cdk synth`, which produces the template, and `cdk deploy`, which applies it.

Writing a real program brings the things programmers are used to: loops, functions, autocompletion, type checks, tests, and packages to share code. A few lines like `new s3.Bucket(this, 'Uploads', { versioned: true })` can expand into dozens of lines of template. Ten similar environments become one loop instead of ten copied files.

The building blocks are **constructs**, which come in levels. Low-level ones map one-to-one to CloudFormation resources. Higher-level ones bundle sensible defaults (a bucket that is encrypted and blocks public access unless you say otherwise), and the highest-level ones assemble whole patterns, like a load-balanced container service. One helper worth knowing: `bucket.grantRead(fn)` writes the IAM policy for you, scoped to exactly that bucket. Each account and Region needs a one-time `cdk bootstrap` before the first deploy.

## An analogy

Building with prefabricated modules instead of drawing every brick. You say "a kitchen here" and the module arrives with plumbing and wiring already done; the city still inspects the final blueprint, which in this case is CloudFormation.

## Keep in mind

- Infrastructure in TypeScript, Python, Java, C# or Go.
- Synthesizes to CloudFormation templates; CloudFormation does the actual deploy.
- Constructs package resources with safe defaults and reusable patterns.
- Helpers like `grantRead` generate least-privilege IAM permissions.

## Go deeper

- [What is the AWS CDK? (official docs)](https://docs.aws.amazon.com/cdk/v2/guide/home.html)
- [AWS Cloud Development Kit](https://aws.amazon.com/cdk/)

## Related terms

- [Infrastructure as code](https://tidbit.legios.com.ar/infrastructure-as-code/): Describing servers, networks and databases in files instead of clicking.
- [Server](https://tidbit.legios.com.ar/server/): A computer whose job is to answer requests from other computers, all day, every day.
- [Python](https://tidbit.legios.com.ar/python/): A popular programming language known for being easy to read and quick to write.
- [AWS CloudFormation](https://tidbit.legios.com.ar/aws-cloudformation/): Describe your AWS infrastructure in a text file; AWS builds it exactly like that.
- [Encryption](https://tidbit.legios.com.ar/encryption/): Scrambling data so that only someone with the key can read it.
- [Container](https://tidbit.legios.com.ar/container/): A sealed box with a program and everything it needs to run anywhere.
- [IAM](https://tidbit.legios.com.ar/iam/): The rulebook that says who can do what in your AWS account.
- [Regions and Availability Zones](https://tidbit.legios.com.ar/regions-and-availability-zones/): Where AWS physically lives: cities worldwide, each split into separate data centers.
