INCIPIT: I wanted to ask if anyone knew how to use codebuild to publish via the (blue/green) method an ecs service with auto scaling and alb.
PROBLEM: when I try to run the stage in deploy codepipeline on ecs, I get a missing artifact error; I actually don’t pass anything to it, wanting to get my image from ECR.
This service is defined in a teskDefinition.json and executed withe terraform.
TaskDefinition:
{
"containerDefinitions": [
{
"name": "test-repo",
"image": "xxxxxxxx.dkr.ecr.eu-west-1.amazonaws.com/nginx-repo",
"cpu": 256,
"memory": 512,
"portMappings": [
{
"containerPort": 80,
"hostPort": 80,
"protocol": "tcp"
}
],
"essential": true,
"environment": [],
"mountPoints": [],
"volumesFrom": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "nginx-server-log-group",
"awslogs-region": "eu-west-1",
"awslogs-stream-prefix": "nginx-server"
}
},
"systemControls": []
}
],
"family": "nginx-server",
"taskRoleArn": "arn:aws:iam::xxxxxxxx:role/nginx-ecs-task-role",
"executionRoleArn": "arn:aws:iam::xxxxxxx:role/ngix-ecs-task-execution-role",
"networkMode": "awsvpc",
"volumes": [],
"placementConstraints": [],
"requiresCompatibilities": [
"FARGATE"
],
"cpu": "256",
"memory": "512",
"tags": [
{
"key": "Name",
"value": "nginx-server"
}
]
}
Terraform:
stage {
name = "Deploy"
action {
name = "Deploy"
category = "Deploy"
owner = "AWS"
input_artifacts = []
provider = "ECS"
version = "1"
configuration = {
ClusterName = "${var.service_name}-ecs-cicd"
ServiceName = var.service_name
FileName = "taskDefinition.json"
}
}
}
I did not introduce an AppSpec, given the duplication of definitions, although I have some doubts about the correctness of this definition.
The goal is to run an ecs with the settings listed above so that it adapts itself, and recreates with blue green protocol, a new service when I launch a new pipeline.