Organize and Deploy VPC Stack using AWS CDK

Organize VPC stack in CDK project

  1. Open the root file Fcj2024CdkApp.

    Step 1

  2. Create a VPC Stack with the ID Vpc using the following code:

    VpcStack vpcStack = new VpcStack(app, "Vpc", StackProps.builder()
                    .build());
    

Architect

  1. Add environment and Tags

    Step 3

Deploy VPC stack

  1. Open a terminal and run the command cdk list to view the list of available tasks. Here, you will see Ecr and Vpc.

    Step 4

  2. Next, run cdk deploy --all to deploy all stacks. When prompted about changeset execution policy, enter y.

    Step 5

  3. Review the changes during deployment. You will see that CDK recognizes that the ECR has not changed and that a new stack for VPC is being created.

    Step 6

Check created resources on AWS Console

  1. Access the AWS Console, navigate to the VPC interface, and select Your VPCs. You should see ECommerceVPC listed.

    Step 7

  2. Similarly, check for Subnets, NAT Gateways, Security Groups, etc.

    Step 8