Something went wrong on our end
-
Nuwan Rajika Kumarasiri authoredNuwan Rajika Kumarasiri authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
ecs.tf 1.58 KiB
data "template_file" "container" {
template = file("./templates/container.tpl")
vars = {
container_name = var.container_name
image_name = var.image_name
fargate_cpu = var.fargate_cpu
fargate_memory = var.fargate_memory
app_port1 = var.container_app_port[0]
app_port2 = var.container_app_port[1]
app_port3 = var.container_app_port[2]
network_mode = var.container_network_mode
informatica_username = var.informatica_username
informatica_password = var.informatica_password
}
}
data "aws_iam_role" "ecs-task-execution" {
name = "ecsTaskExecutionRole"
}
resource "aws_ecs_task_definition" "task" {
family = var.ecs_task_name
execution_role_arn = data.aws_iam_role.ecs-task-execution.arn
network_mode = var.container_network_mode
requires_compatibilities = [
"FARGATE"]
cpu = var.fargate_cpu
memory = var.fargate_memory
container_definitions = data.template_file.container.rendered
}
resource "aws_ecs_service" "service" {
name = var.ecs_service_name
cluster = aws_ecs_cluster.cluster.id
task_definition = aws_ecs_task_definition.task.arn
desired_count = 1
launch_type = "FARGATE"
network_configuration {
security_groups = [
data.aws_security_group.sec-group.id]
subnets = data.aws_subnet_ids.subnets.ids
assign_public_ip = false
}
}
resource "aws_ecs_cluster" "cluster" {
name = var.ecs_cluster_name
tags = var.ecs_cluster_tags
}