This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_lb_target_group" "target_group" { | |
name = "target-group" | |
port = 80 | |
protocol = "HTTP" | |
target_type = "ip" | |
vpc_id = "${aws_default_vpc.default_vpc.id}" # Referencing the default VPC | |
health_check { | |
matcher = "200,301,302" | |
path = "/" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_alb" "application_load_balancer" { | |
name = "test-lb-tf" # Naming our load balancer | |
load_balancer_type = "application" | |
subnets = [ # Referencing the default subnets | |
"${aws_default_subnet.default_subnet_a.id}", | |
"${aws_default_subnet.default_subnet_b.id}", | |
"${aws_default_subnet.default_subnet_c.id}" | |
] | |
# Referencing the security group | |
security_groups = ["${aws_security_group.load_balancer_security_group.id}"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 we want deployed to 3 | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Providing a reference to our default VPC | |
resource "aws_default_vpc" "default_vpc" { | |
} | |
# Providing a reference to our default subnets | |
resource "aws_default_subnet" "default_subnet_a" { | |
availability_zone = "eu-west-2a" | |
} | |
resource "aws_default_subnet" "default_subnet_b" { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 we want deployed to 3 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# General setup | |
provider "aws" { | |
version = "~> 2.0" | |
region = "eu-west-2" # Setting our region | |
} | |
# Providing a reference to our default VPC | |
resource "aws_default_vpc" "default_vpc" { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_ecs_task_definition" "my_first_task" { | |
family = "my-first-task" # Naming our first task | |
container_definitions = <<DEFINITION | |
[ | |
{ | |
"name": "my-first-task", | |
"image": "${aws_ecr_repository.my_first_ecr_repo.repository_url}", | |
"essential": true, | |
"portMappings": [ | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_ecs_task_definition" "my_first_task" { | |
family = "my-first-task" # Naming our first task | |
container_definitions = <<DEFINITION | |
[ | |
{ | |
"name": "my-first-task", | |
"image": "${aws_ecr_repository.my_repo.repository_url}", | |
"essential": true, | |
"portMappings": [ | |
{ |