Organize and Deploy Stack

Organize ProductsServiceStack Stack

  1. Open the root file Fcj2024CdkApp:

    Architect

  2. Create and Set Tags:

    • Create a Map named productsServiceTags to define tags for the stack and related resources. Tags are stored as key-value pairs in the map.

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

Architect

  1. Create Stack ProductsServiceStack
 ProductsServiceStack productsServiceStack = new ProductsServiceStack(app, "ProductsService",
                StackProps.builder()
                        .env(environment)
                        .tags(productsServiceTags)
                        .build(),
                new ProductsServiceProps(
                        vpcStack.getVpc(),
                        clusterStack.getCluster(),
                        nlbStack.getNetworkLoadBalancer(),
                        nlbStack.getApplicationLoadBalancer(),
                        ecrStack.getProductsServiceRepository()));

Architect

  1. Add Dependencies to Ensure VPC, Cluster, NLB, and ECR are Created Before Creating the Service:
   productsServiceStack.addDependency(vpcStack);
   productsServiceStack.addDependency(clusterStack);
   productsServiceStack.addDependency(nlbStack);
   productsServiceStack.addDependency(ecrStack);

Architect

Deploy ProductsService Stack using AWS CDK

  1. Open a terminal and run the following command to deploy:
cdk deploy --all --require-approval never

Architect

  1. After successful deployment, access the AWS Management Console. Navigate to ECS:

Architect

  1. In the ECS dashboard, you can see a cluster named ECommerce has been created along with 2 running tasks:

Architect

  1. Select the ECommerce cluster and then choose a task to view details about the created tasks:

Architect