terraform { required_version = ">= 1.5.0" required_providers { aws = { source = "hashicorp/aws" version = ">= 5.0, < 7.0" } } } provider "aws" { region = var.aws_region } locals { telemetry_environment = { PORT = "8080" OTEL_SERVICE_NAME = var.service_name OTEL_RESOURCE_ATTRIBUTES = "service.namespace=commerce,deployment.environment.name=${var.environment},service.version=${var.release}" OTEL_TRACES_EXPORTER = "otlp" OTEL_METRICS_EXPORTER = "none" OTEL_LOGS_EXPORTER = "none" OTEL_EXPORTER_OTLP_PROTOCOL = "http/protobuf" OTEL_EXPORTER_OTLP_ENDPOINT = var.corridora_endpoint OTEL_PROPAGATORS = "tracecontext,baggage" OTEL_TRACES_SAMPLER = "parentbased_always_on" } } resource "aws_ecs_task_definition" "api" { family = var.task_family network_mode = "awsvpc" requires_compatibilities = ["FARGATE"] cpu = "256" memory = "512" execution_role_arn = var.execution_role_arn task_role_arn = var.task_role_arn container_definitions = jsonencode([ { name = "shop-api" image = var.image essential = true portMappings = [{ containerPort = 8080, protocol = "tcp" }] environment = [ for name, value in merge(var.application_environment, local.telemetry_environment) : { name = name, value = value } ] secrets = [{ name = "OTEL_EXPORTER_OTLP_HEADERS" valueFrom = var.otlp_headers_secret_arn }] } ]) } output "task_definition_arn" { description = "Registering a task definition does not update an ECS service." value = aws_ecs_task_definition.api.arn }