diff --git a/ecs/appspec.yml b/ecs/appspec.yml new file mode 100644 index 0000000..d65cc61 --- /dev/null +++ b/ecs/appspec.yml @@ -0,0 +1,11 @@ +--- +version: 0.0 +Resources: + - TargetService: + Type: AWS::ECS::Service + Properties: + TaskDefinition: "" + LoadBalancerInfo: + ContainerName: "foo-app" + ContainerPort: 4000 + PlatformVersion: "LATEST" diff --git a/ecs/task-definition.json.jq b/ecs/task-definition.json.jq new file mode 100644 index 0000000..9845ec9 --- /dev/null +++ b/ecs/task-definition.json.jq @@ -0,0 +1,125 @@ +{ + "family": "foo-api", + "taskRoleArn": env.TASK_ROLE_ARN, + "executionRoleArn": env.EXECUTION_ROLE_ARN, + "networkMode": "awsvpc", + "cpu": "256", + "memory": "512", + "requiresCompatibilities": ["FARGATE"], + "runtimePlatform": {"cpuArchitecture": "X86_64"}, + "containerDefinitions": [ + { + "cpu": 0, + "dependsOn": [ + { + "containerName": "aws-otel-collector", + "condition": "START" + } + ], + "environment": [ + { + "name": "GITHUB_SHA", + "value": env.GITHUB_SHA + }, + { + "name": "GITHUB_HEAD_REF", + "value": env.GITHUB_HEAD_REF + }, + { + "name": "LIBCLUSTER_STRATEGY", + "value": "dns" + }, + { + "name": "OTEL_EXPORTER_OTLP_ENDPOINT", + "value": "http://localhost:4317" + }, + { + "name": "OTEL_EXPORTER_OTLP_PROTOCOL", + "value": "grpc" + }, + { + "name": "OTEL_RESOURCE_ATTRIBUTES", + "value": "aws.log.group.names=/ecs/foo-api" + }, + { + "name": "OTEL_SERVICE_NAME", + "value": "foo-api" + }, + { + "name": "ROLES", + "value": "api" + } + ], + "essential": true, + "image": "", + "logConfiguration": { + "logDriver": "awslogs", + "options": { + "awslogs-create-group": "true", + "awslogs-group": "/ecs/foo-api", + "awslogs-region": env.AWSLOGS_REGION, + "awslogs-stream-prefix": "foo-api" + } + }, + "mountPoints": [], + "name": "foo-api", + "portMappings": [ + { + "appProtocol": "http", + "containerPort": 4001, + "hostPort": 4001 + } + ], + "readonlyRootFilesystem": false, + "entryPoint": ["bin/start-docker"], + "secrets": [ + { + "name": "DATABASE_URL", + "valueFrom": "arn:aws:ssm:\(env.AWS_REGION):\(env.AWS_ACCOUNT_ID):parameter/\(env.AWS_PS_PREFIX)/app/db/url" + }, + { + "name": "PHX_HOST", + "valueFrom": "arn:aws:ssm:\(env.AWS_REGION):\(env.AWS_ACCOUNT_ID):parameter/\(env.AWS_PS_PREFIX)/app/endpoint/host" + }, + { + "name": "RELEASE_COOKIE", + "valueFrom": "arn:aws:ssm:\(env.AWS_REGION):\(env.AWS_ACCOUNT_ID):parameter/\(env.AWS_PS_PREFIX)/app/release_cookie" + }, + { + "name": "SECRET_KEY_BASE", + "valueFrom": "arn:aws:ssm:\(env.AWS_REGION):\(env.AWS_ACCOUNT_ID):parameter/\(env.AWS_PS_PREFIX)/app/endpoint/secret_key_base" + } + ], + "startTimeout": 30, + "stopTimeout": 30 + }, + { + "name": "aws-otel-collector", + "image": "\(env.ECR_REGISTRY)/\(env.ECR_IMAGE_OWNER)aws-otel-collector", + "cpu": 0, + "environment": [ + { + "name": "AWS_REGION", + "value": env.AWSLOGS_REGION + } + ], + "essential": true, + "healthCheck": { + "command": [ "/healthcheck" ], + "interval": 5, + "timeout": 6, + "retries": 5, + "startPeriod": 1 + }, + "logConfiguration": { + "logDriver": "awslogs", + "options": { + "awslogs-create-group": "true", + "awslogs-group": "/ecs/ecs-aws-otel-sidecar-collector", + "awslogs-region": env.AWSLOGS_REGION, + "awslogs-stream-prefix": "foo-api" + } + } + } + ] +}