Creating an aws instance in windows and setup

1)Need to create an account in aws

2)Add the creds

3)Go to Identity and Access Management (IAM)

4)Click on users and create a user giving any random name give policy access and give administrator access

5)Add aws cli interface in the system

6)Check version with aws —v and also add aws configure

7)Paste the access id and secret key and also default region, with json format

8)Check with command aws s3 -l, to check the right installation, done

Installation of cdk

1)bun i -g aws-cdk

2)check version cdk —v

Initialisiing a cdk-aws

1)cdk init

Note:- Contains 3 types, 1)app, sample-app,lib

2)cdk init —language=typescipt

To deploy the cdk

1)cdk bootstrap 2

2)cdk deploy

3)Check in the cloud formation

4)Note cdk.out will be created and the files inside will be deployed to aws cdk formation cloud

Note - cdk synth will only generate a template

CDK Constructs

-cdk constructs are basic building blocks of cdk application

-3 types of constructs are there,

1)Level 1 — offers no abstraction need to configure everything

2)Level 2 — preferably used, offers additional functionality

3)Level 3 — commonly called patterns , combine multiple types of resources and help with the common tasks in aws

Creating a demo cdk with three options

class L3Bucket extends Construct {
  constructor(scope: Construct, id: string, expiration: number) {
    super(scope, id);
    new Bucket(this, "L3Bucket", {
      lifecycleRules: [
        {
          expiration: Duration.days(expiration),
        },
      ],
    });
  }
}
export class CdkStarterStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    //create a s3 bucket 3 ways
    //this is the L1 way
    new CfnBucket(this, "MyL1Bucket", {
      lifecycleConfiguration: {
        rules: [
          {
            expirationInDays: 1,
            status: "Enabled",
          },
        ],
      },
    });

    // this is the L2 way
    new Bucket(this, "MyL2Bucket", {
      lifecycleRules: [
        {
          expiration: Duration.days(2),
        },
      ],
    });
    // this is the L3 way of constructing a bucket
    new L3Bucket(this, "MyL3Bucket", 3);
  }
}