Public documentation

Documentation indexRead as Markdown

Terraform: configure an ECS application exporter

Use Terraform's AWS provider to define an instrumented application's ECS task configuration. Corridora receives ordinary OTLP telemetry; this recipe does not require a Corridora Terraform provider or create Corridora organizations and keys.

The example registers a minimal Fargate task definition and outputs its ARN. Service rollout is an explicit separate step, so you can use your existing deployment controller.

Prerequisites and scope

  • Terraform 1.5 or newer and an AWS provider version satisfying the example constraints.
  • An existing ECS cluster/service, networking, load balancer, and secret.
  • An instrumented image listening on port 8080, built using Docker setup and the appropriate language guide.
  • AWS credentials with task-definition permissions and permission to pass the existing execution/task roles.
  • A task execution role that can retrieve the secret and pull the image, plus outbound HTTPS from the tasks to Corridora.

Use a dedicated example service or adapt the module to match your existing container names, resources, health checks, sidecars, logging, and volumes. Do not replace a production definition's other requirements with the minimal sample.

Copy the example

Copy these files together into a deployment directory:

Rename the variable example to terraform.tfvars and replace its identifiers. Use an immutable image reference for a reproducible release. The execution role and secret ARN must exist in the deployment's account/region.

The existing Secrets Manager secret must contain:

X-CORRIDORA-KEY=YOUR_BACKEND_INGEST_KEY

The configuration stores only its ARN in container_definitions. ECS resolves its value at task startup. Do not add the actual key to application_environment, a Terraform output, or a local-exec command.

Understand the generated configuration

The module configures the standard OTLP/HTTP protobuf exporter, a stable service.name, release/environment attributes, and W3C propagation. It starts with traces enabled and logs/metrics disabled. The image must contain the matching instrumentation and exporter.

The credential uses the native ECS secret-reference field:

secrets = [{
  name      = "OTEL_EXPORTER_OTLP_HEADERS"
  valueFrom = var.otlp_headers_secret_arn
}]

The module does not read aws_secretsmanager_secret_version.secret_string. Marking a Terraform variable sensitive hides some output but does not generally remove its value from state. Reference existing secrets, use a protected state backend, and restrict access to saved plan files.

Validate, review, and apply

Run from the copied example directory with AWS authentication supplied through your existing workflow:

terraform init
terraform fmt -check
terraform validate
terraform plan -out=telemetry.tfplan
terraform apply telemetry.tfplan

Review the plan before applying. Commit the provider lockfile so later initialization selects the reviewed provider versions. Keep state and saved plans out of public source directories. terraform validate checks configuration consistency; it does not prove IAM, image availability, network access, or exporter delivery.

If Terraform already manages this task family, integrate the resource into that configuration instead of creating another owner for the same deployment. If it manages the ECS service too, change its task_definition reference there rather than creating out-of-band service drift.

Roll out through the existing service

For a service managed outside Terraform using the standard ECS rolling deployment path:

export AWS_REGION=us-east-1
export ECS_CLUSTER=YOUR_CLUSTER
export ECS_SERVICE=YOUR_SERVICE

TASK_DEFINITION_ARN=$(terraform output -raw task_definition_arn)
aws ecs update-service \
  --cluster "$ECS_CLUSTER" --service "$ECS_SERVICE" \
  --task-definition "$TASK_DEFINITION_ARN"
aws ecs wait services-stable \
  --cluster "$ECS_CLUSTER" --services "$ECS_SERVICE"

A new secret value alone does not change the task-definition ARN or refresh running task environments. Plan a new task deployment for rotation. Use key replacement to avoid losing telemetry during the change.

Verify collection and correlation

Apply the AWS forwarding configuration and install RUM. Terraform's infrastructure graph does not establish trace parentage: the runtime must extract incoming context and inject outgoing context.

Run deployment verification. Check the deployed task revision, generated service/resource identity, an uncached browser request, and stored matching browser/backend trace IDs. If the service is healthy but no traces arrive, inspect the app's instrumentation and secret/network access rather than repeatedly applying an unchanged plan.