Skip to content

Instantly share code, notes, and snippets.

@AndrewBestbier
Created March 11, 2020 13:00
Show Gist options
  • Select an option

  • Save AndrewBestbier/e3df3604859931e61ba84e8eb67d4b67 to your computer and use it in GitHub Desktop.

Select an option

Save AndrewBestbier/e3df3604859931e61ba84e8eb67d4b67 to your computer and use it in GitHub Desktop.
resource "aws_ecs_service" "my_first_service" {
name = "my-first-service" # Naming our first service
cluster = "${aws_ecs_cluster.my_cluster.id}" # Referencing our created Cluster
task_definition = "${aws_ecs_task_definition.my_first_task.arn}" # Referencing the task our service will spin up
launch_type = "FARGATE"
desired_count = 3 # Setting the number of containers to 3
load_balancer {
target_group_arn = "${aws_lb_target_group.target_group.arn}" # Referencing our target group
container_name = "${aws_ecs_task_definition.my_first_task.family}"
container_port = 3000 # Specifying the container port
}
network_configuration {
subnets = ["${aws_default_subnet.default_subnet_a.id}", "${aws_default_subnet.default_subnet_b.id}", "${aws_default_subnet.default_subnet_c.id}"]
assign_public_ip = true # Providing our containers with public IPs
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment