I got this error on my pipeline,i am trying to test a gree/blue deployment. my task definition looks like this.
"executionRoleArn": "arn:aws:iam::4634380474765:role/ecsTaskExecutionRole",
"containerDefinitions": [
{
"name": "containername",
"image": "<IMAGE_NAME>",
"essential": true,
"portMappings": [
{
"hostPort": 80,
"protocol": "tcp",
"containerPort": 80
}
]
}
],
"requiresCompatibilities": [
"FARGATE"
],
"networkMode": "awsvpc",
"cpu": "256",
"memory": "512",
"family": "myTaskDefination"
}
version: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR.....
- aws --version
- echo $$AWS_DEFAULT_REGION
- REPOSITORY_URI=account.dkr.ecr.ap-southeast-2.amazonaws.com/tv2testenv
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $REPOSITORY_URI
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=${COMMIT_HASH:=latest}
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- docker build -t $REPOSITORY_URI:latest .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker images...
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- printf '{"ImageURI":"%s"}' $REPOSITORY_URI:$IMAGE_TAG > imageDetail.json
artifacts:
files:
- appspec.yml
- taskdef.json
- imageDetail.json
appspec.yml
version: 0.0
Resources:
- TargetService:
Type: AWS::ECS::Service
Properties:
TaskDefinition: <TASK_DEFINITION>
LoadBalancerInfo:
ContainerName: "Containername"
ContainerPort: 80
pipeline.json
{
"name": "Deploy",
"actions": [
{
"name": "Deploy",
"actionTypeId": {
"category": "Deploy",
"owner": "AWS",
"provider": "CodeDeployToECS",
"version": "1"
},
"runOrder": 1,
"configuration": {
"AppSpecTemplateArtifact": "BuildArtifact",
"ApplicationName": "odeDeploy",
"DeploymentGroupName": "DeploymentGroup",
"Image1ArtifactName": "BuildArtifact",
"Image1ContainerName": "<IMAGE_URL>",
"TaskDefinitionTemplateArtifact": "BuildArtifact"
},
"outputArtifacts": [],
"inputArtifacts": [
{
"name": "BuildArtifact"
}
],
}
]
}
The error is thrown from part of the pipeline above, complaining about the Image1ContainerName. I cannot seem to figure out what i did wrong. The Image1ContainerName isn't it suppose to be the image url?
You set your CodePipeline to use IMAGE_URI
as the Dynamic update task definition.
While your task definition is using:
"image": "<IMAGE_NAME>",
The simplest solution would be changing the task definition to use
"image": "<IMAGE_URI>",