-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecs.tf
67 lines (54 loc) · 1.71 KB
/
ecs.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Defines ECS Cluster
module "ecs" {
source = "terraform-aws-modules/ecs/aws"
name = var.cluster_name
container_insights = true
capacity_providers = ["FARGATE", "FARGATE_SPOT"]
default_capacity_provider_strategy = [
{
capacity_provider = var.capacity_provider
weight = "1"
}
]
tags = {
Environment = "Development"
}
}
# ECS Service Definition
resource "aws_ecs_service" "netmiko-web" {
name = var.task_name
cluster = module.ecs.ecs_cluster_arn
task_definition = aws_ecs_task_definition.netmiko-web.arn
desired_count = var.desired_container_count
network_configuration {
subnets = module.vpc.public_subnets
security_groups = [module.sg.id]
assign_public_ip = true
}
}
# ECS Task Definition
module "container" {
source = "cloudposse/ecs-container-definition/aws"
container_name = var.task_name
container_image = var.container_image
container_memory = 512
container_memory_reservation = 512
working_directory = "/app"
port_mappings = [
{
containerPort = 5000
hostPort = 5000
protocol = "tcp"
}
]
}
resource "aws_ecs_task_definition" "netmiko-web" {
family = "netmiko"
cpu = 256
memory = 512
container_definitions = module.container.json_map_encoded_list
#execution_role_arn = "arn:aws:iam::726617996409:role/aws-service-role/ecs.amazonaws.com/AWSServiceRoleForECS"
requires_compatibilities = ["FARGATE"]
network_mode = "awsvpc"
tags = var.tags
}