I set up CircleCI, Amazon ECS, and ECR in an environment where Docker containers are continuously deployed, put Assets files (CSS, JS) in a bucket of s3, and sent them to CloudFront for deployment. I would like to briefly summarize the series of steps.
--Select EC2 Linux + Networking for cluster template --Enter the cluster name ex) sample-cluster --Create an empty cluster --Do not set the instance here
--Select amzn2-ami-ecs-hvm-2.0 for AMI --Select t2.micro for the instance size --Select a network (vpc) --Select a subnet --Select the role (created) of Instance of ecs in IAM role --Enter user data as follows --Enter the cluster name in place of YOUR_CLUSTER_NAME
#!/bin/bash echo ECS_CLUSTER=YOUR_CLUSTER_NAME >> /etc/ecs/ecs.config
--Create a new security group --Create a key pair
--Choose private --Enter the repository name ex) sample-repository
--Select EC2 as the type --Enter the definition name ex) sample-task --Select ecsTaskExecutionRole for the role --Select bridge for network --If you want to know about the network, please refer to this site. --Do not select the task size here, select the size in the container --Enter the container name ex) sample-app --Enter the image with a tag attached to the ECR URI created earlier ex) xxxxxxxxxxxxx.com/sample-repository:latest --Insert memory limit --At first, 300-500 may be fine --I want the port to be dynamic port mapping, so set the host to 0 and the container to 80.
--Enter the ALB name ex) alb-sample --Insert listener ex) HTTP, HTTPS --Enter the Availability Zone and select the same vpc as when you created the EC2 instance. --Select a subnet --Choose a server certificate --Select the security group created when creating the EC2 instance --Create a new target group --Select an instance as the target type
--Select EC2 as the startup type --Select the task created earlier ex) sample-task --Select the cluster created earlier ex) sample-cluster --Enter the service name ex) sample-service --Select 1 for the number of tasks for now --ALB chooses the one you selected earlier --Select the target group you created earlier
The above is a rough ECS and ECR setup procedure.
I will summarize this in the next article! !!