Reputation: 1969
I have a Codepipeline that deploys an ECR image to an ECS cluster using an ECS Blue / Green Deployment action. The pipeline contains two sources: one for the ECR image using an AWS ECR action and another one for fetching the configuration from Github using a ThirdParty Github action. The ECR action outputs an image
artifact while the Github action outputs a config
artifact. Both of these artifacts are provided as an input to the ECS Blue / Green Deployment action.
The pipeline fails at the ECS Blue / Green Deployment action with the following error (visible from AWS console):
Invalid action configuration
Exception while trying to read the task definition artifact file from: config
Here is the structure of the pipeline (some details are edited for anonymity):
$ aws codepipeline get-pipeline --name my-codepipeline
{
"pipeline": {
"name": "my-codepipeline",
"roleArn": "arn:aws:iam::123456789000:role/my-codepipeline-role",
"artifactStore": {
"type": "S3",
"location": "my-codepipeline-s3"
},
"stages": [
{
"name": "Source",
"actions": [
{
"name": "ImageSource",
"actionTypeId": {
"category": "Source",
"owner": "AWS",
"provider": "ECR",
"version": "1"
},
"runOrder": 1,
"configuration": {
"ImageTag": "latest",
"RepositoryName": "my-ecr"
},
"outputArtifacts": [
{
"name": "image"
}
],
"inputArtifacts": []
},
{
"name": "ConfigSource",
"actionTypeId": {
"category": "Source",
"owner": "ThirdParty",
"provider": "GitHub",
"version": "1"
},
"runOrder": 1,
"configuration": {
"Branch": "master",
"OAuthToken": "****",
"Owner": "me",
"PollForSourceChanges": "false",
"Repo": "application-config"
},
"outputArtifacts": [
{
"name": "config"
}
],
"inputArtifacts": []
}
]
},
{
"name": "Deploy",
"actions": [
{
"name": "DeployBackend",
"actionTypeId": {
"category": "Deploy",
"owner": "AWS",
"provider": "CodeDeployToECS",
"version": "1"
},
"runOrder": 1,
"configuration": {
"AppSpecTemplateArtifact": "config",
"AppSpecTemplatePath": "production/appspec.yaml",
"ApplicationName": "my-codedeploy",
"DeploymentGroupName": "my-codedeploy-group",
"Image1ArtifactName": "image",
"Image1ContainerName": "IMAGE_NAME",
"TaskDefinitionTemplateArtifact": "config",
"TaskDefinitionTemplatePath": "production/taskdef.json"
},
"outputArtifacts": [],
"inputArtifacts": [
{
"name": "image"
},
{
"name": "config"
}
]
}
]
}
],
"version": 1
},
"metadata": {
"pipelineArn": "arn:aws:codepipeline:ap-northeast-1:123456789000:my-codepipeline",
"created": 1564107543.285,
"updated": 1564107543.285
}
}
I have checked the compressed artifact in the S3 and it definitely contains the configuration files in the Github repository at the location specified by AppSpecTemplatePath
and TaskDefinitionTemplatePath
.
Here is the content of appspec.yaml
:
$ cat production/appspec.yaml
version: 0.0
Resources:
- TargetService:
Type: AWS::ECS::Service
Properties:
TaskDefinition: <TASK_DEFINITION>
LoadBalancerInfo:
ContainerName: "my-container"
ContainerPort: 80
Upvotes: 6
Views: 11056
Reputation: 863
The moment my project's SourceArtifact size grew beyond 3MB, I ran into this issue. To solve it, I added the following to my buildspec.yml
file. The config/aws
folder in my project contains the taskdef.json
and appspec.yml
files.
artifacts:
files:
- 'config/aws/*'
I named my output artifact BuildArtifact
in CodeBuild and configured this as the input artifact for CodeDeploy, making sure to configure the Amazon ECS task definition
and AWS CodeDeploy AppSpec file
inputs accordingly.
Upvotes: 0
Reputation: 1504
As far as I understand there are three major things we have to check as even if there is a syntax issue on file we might get the exception
[1] Tutorial: Create a Pipeline with an Amazon ECR Source and ECS-to-CodeDeploy Deployment - https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-ecs-ecr-codedeploy.html
Upvotes: 1
Reputation: 180
Thought I know a little about artifact config and could not found any help.
I created another codecommit repo where i stored appspec.yml and taskdef.json file only and followed this aws userguide. And this worked
Previously I was committing those file with main project repo. But every time it failed in deploy state with this message.[Exception while trying to read the task definition artifact file from ...]
I felt safe this way in production codebuild and codedeploy are separated in pipeline.
I created artifact pipeline and build pipeline. Two pipeline. To blue/green ECS service.
Upvotes: 1
Reputation: 1969
After extensively trying out things, I stumbled upon a thread in a foreign language which I cannot find it. The thread said something about the artifact being passed to the action cannot be larger than 3 MB.
I solved my problem by reducing the size of the artifact (config
). The configuration repository is shared among many projects and by moving those items to another project, I decreased the compressed artifact size from 14 MB to 3 kB. Miraculously, everything worked fine. AWS if you are reading this, please add more documentation about the artifact size limits to ECS CodeDeploy as I don't see any mention about this and I have no way of debugging this problem with such a general error message.
Upvotes: 13