Organize CDK Stack in CDK Project

Organize CDK Stack in CDK Project

  1. Open the root file Fcj2024CdkApp.

Architect

  1. Create an ECR Stack using the following code snippet:

    EcrStack ecrStack = new EcrStack(app, "Ecr", StackProps.builder().build());
    

Architect

  1. Create an Environment using the following code:

    Environment environment = Environment.builder()
        .account("your_account_id")
        .region("ap-southeast-1")
        .build();
    
    • Replace your_account_id with your AWS account ID.
    • Use ap-southeast-1 as the desired AWS region for resource creation.

    Architect Architect

  2. Add the Environment to the ECRStack using the following code:

    .env(environment)
    

    Architect

  3. Create properties infraTags for Tags:

    Map<String, String> infraTags = new HashMap<>();
    infraTags.put("team", "FirstCloudJourney");
    infraTags.put("cost", "ECommerceInfra");
    

    Architect

  4. Apply Tags to the ECRStack:

    .tags(infraTags)
    

    Architect

  5. Check the stacks that CDK will create for CloudFormation using the command:

    cdk list
    
    • Here, CDK shows that only one stack (Ecr) will be created.

    Architect

  6. To prepare the deployment environment for CDK applications on AWS, including creating necessary resources for deployment and managing CDK applications effectively on the AWS platform, run the command:

    cdk bootstrap --profile default
    

    Architect

  7. To view the resources created after running cdk bootstrap –profile default, access the AWS console and navigate to CloudFormation.

    Architect

  8. In the CloudFormation interface, you can see a CDKToolkit stack has been created.

    Architect

  9. Select CDKToolkit and then choose the Resources tab to view the created resources.

    Architect