In this step, we will deploy the ProductsServiceEcrStack to our AWS account using the AWS CDK CLI, monitor the CloudFormation resource creation process, and verify the ECR repository in the AWS Management Console.
Before any stack can be deployed, the AWS environment (Account & Region) must be bootstrapped with management resources (S3 bucket for assets, CDK IAM roles).
Check account information:
aws sts get-caller-identity --output text
Run the bootstrap command:
npx cdk bootstrap

Access the AWS Console -> CloudFormation -> Stacks -> Select stack CDKToolkit.



cdk deploy)Open Terminal in VS Code at the IaC-ECS-CDK/cdk directory.
Run the command to deploy only the ECR Stack:
npx cdk deploy ProductsServiceEcrStack --require-approval never
Parameter meaning:
The –require-approval never parameter directs CDK to automatically approve security-related changes (such as IAM Roles or Resource Policies) without stopping to ask the user to type y/n, allowing the deployment process to run smoothly.

Save the RepositoryUri value displayed in the Outputs section. This is the unique registry identifier on AWS ECR, which will be used for tagging and pushing the Docker image in the next step.


Sign in to the AWS Management Console.
In the top search bar, type ECR and select the Elastic Container Registry service. Ensure you have selected the correct region Singapore (ap-southeast-1) in the upper right corner.

fcaj-products-service appear in the list.
fcaj-products-service to view details.
Currently, the repository is newly created, so there are no images yet. We will proceed to authenticate Docker and push the image to this repository in the next step.