QA
Intermediate LevelCloud Computing (AWS/GCP/Azure)

What is the AWS Cloud Development Kit (CDK) and how does it synthesize CloudFormation stacks using TypeScript?

❓ Interview Prompt: Explain AWS CDK constructs (L1, L2, L3), imperative programming for IaC, and synthesis into CloudFormation templates.

The AWS Cloud Development Kit (CDK) is an open-source software development framework to define cloud infrastructure using familiar programming languages (TypeScript, Python, Java).

CDK Construct Levels:

1
L1 Constructs (Cfn Resources): Direct 1-to-1 mappings of low-level CloudFormation resources (e.g. 'CfnBucket').
2
L2 Constructs (AWS Intent-Based): High-level abstractions with sensible security defaults, auto-generated IAM roles, and boilerplate reduction (e.g. 's3.Bucket').
3
L3 Constructs (Patterns): Complete architecture solutions combining multiple services (e.g. 'ApplicationLoadBalancedFargateService').
4
Synthesis: Running 'cdk synth' compiles imperative code into standard declarative CloudFormation YAML/JSON templates!

Code Implementation Example

typescript
import * as cdk from 'aws-cdk-lib';
import * as s3 from 'aws-cdk-lib/aws-s3';
import { Construct } from 'constructs';

export class MyInfrastructureStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    // L2 Construct creating encrypted S3 bucket with auto defaults
    new s3.Bucket(this, 'MySecureBucket', {
      versioned: true,
      encryption: s3.BucketEncryption.S3_MANAGED,
      removalPolicy: cdk.RemovalPolicy.DESTROY
    });
  }
}
💡Defining AWS infrastructure using AWS CDK in TypeScript.
🎯 Interview Key Takeaway

AWS CDK uses object-oriented programming languages to synthesize secure, declarative CloudFormation templates.

#AWS CDK#TypeScript#Constructs#IaC#Intermediate
Back to all Cloud Computing (AWS/GCP/Azure) Questions→

More Cloud Computing (AWS/GCP/Azure) Interview Questions

Beginner LevelCloud Computing (AWS/GCP/Azure)

How does Serverless Architecture (AWS Lambda / GCP Cloud Run) handle Auto-Scaling and Cold Starts?

Beginner LevelCloud Computing (AWS/GCP/Azure)

What is the difference between IaaS, PaaS, and SaaS cloud service models?

Beginner LevelCloud Computing (AWS/GCP/Azure)

What is AWS EC2 and what are On-Demand, Reserved, and Spot Instance pricing models?