Question:
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):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
$ 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
:
1 2 3 4 5 6 7 8 9 10 11 |
$ cat production/appspec.yaml version: 0.0 Resources: - TargetService: Type: AWS::ECS::Service Properties: TaskDefinition: LoadBalancerInfo: ContainerName: "my-container" ContainerPort: 80 |
Answer:
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.