All technological notes.
| DevOps Steps | Development | Production |
|---|---|---|
| Build | Local build | Jenkins |
| Push | Local Development env with Docker Compose | ECR |
| Run | Local Development env with Docker Compose | ECS |
resource "aws_ecr_repository" "myapp" {
name = "myapp"
image_tag_mutability = "MUTABLE"
image_scanning_configuration {
scan_on_push = true
}
}
output "myapp-ecr-url" {
value = aws_ecr_repository.myapp.repository_url
}
# push image to ecr created by tf
aws ecr get-login
docker push ecr_url/myapp
# build with image on ecr
docker build -t ecr_url/myapp
ECS = EC2 + ECS agent
Create ECS cluster
resource "aws_ecs_cluster" "ecs_cluster" {
name = "ecs_cluster"
}
resource "aws_launch_template" "ecs_instance_template" {
name_prefix = "ecs_instance"
image_id = var.image_id
instance_type = var.instance_type
}
resource "aws_autoscaling_group" "ecs_auto_group" {
availability_zones = ["${var.aws_region}"]
desired_capacity = 1
max_size = 1
min_size = 1
launch_template {
id = aws_launch_template.ecs_instance_template.id
version = "$Latest"
}
}
Task definition: describe what to be run within docker container
Service definition: describe the container based on the task definition.