- clone
- cd terraform-learning-example
- Create an EC2 Key Pair (Optional)
- Add your container image url in "container-definitions.json" file.
terraform init
terraform plan
terraform apply
- Scale down EC2 auto scaling group
- Terminate EC2 instances
- Run
terraform destroy
alb.tf
- also known as "Application Load Balancer". This is a load balancer configured for EC2 instances. It consists of 3 main parts:
- aws_lb - main load balancer configuration.
- aws_lb_target_group - load balancer security target group using region VPC as subnets.
- aws_lb_listener - the route request enabled to be recieved by load balancer.
ami.tf
- also known as "Amazon Machine Images". This is an image configuration for running EC2 instances via launch configuration on autoscaling group.
asg.tf
- also known as "Autoscaling Group". This enables scale out configuration of EC2 instances and requires the load balancer arn.
Details:
aws_launch_configuration
- resource configuration to launch auto scale for EC2 instances via Load Balancer.aws_autoscaling_group
- main configuration for auto scaling EC2 instances.
ecs.tf
- also known as "Elastic Container Service". A service holding out container instances.
Details:
aws_ecs_capacity_provider
- provides scaling of ECS instances.aws_ecs_cluster
- main resource that holds ECS tasks and instances.aws_ecs_cluster_capacity_providers
- defines the capacity provider used in the cluster.aws_ecs_task_definition
- configurations for the containers.aws_ecs_service
- main resource to run ECS instances.aws_cloudwatch_log_group
- cloudwatch resource attached to our ecs instances for log tracing.
iam.tf
- also known as "Identity and Access Management". This provides role accesses for certain resources.
main.tf
- declare providers.
outputs.tf
- get outputs from resources and print it once you run the terraform command.
security-group.tf
- declare security groups that is required by other resources.
variables.tf
- setup for input items that can be provided inside terraform execution.
vpc.tf
- also known as "Virtual Private Cloud". Using a terraform vpc module, creation of private network with high availability can be achieved and be used by other resources that requires it.