AWS, CI/CD

AWS code pipeline common issues

This is my first time experience aws code build. I encountered many issues so I would like to share with you guys, in order to help saving your time.

Message issueSolution
Cannot have more than 0 builds in queue for the account
We need to request more quota, minimum 1 build for your region. So please create a case support. So they will give you quota. It’s easy, just wait for 1 or 2 days business time.
YAML_FILE_ERROR Message: Unknown runtime named ‘docker’. This build image has the following runtimes: dotnet, golang, java, nodejs, php, python, rubyI normally remove or comment out install section and it worked.
# install:
# runtime-versions:
# docker: latest
Relevant permission deniedJust add more “action” to the roles based on the message.
COMMAND_EXECUTION_ERROR Message: Error while executing command: $(aws ecr get-login-password –region $AWS_DEFAULT_REGION | docker login –username AWS –password-stdin 183350198843.dkr.ecr.ap-southeast-1.amazonaws.com). Reason: exit status 127Please remove $(). Only use the command inside.
– aws ecr get-login-password –region $AWS_DEFAULT_REGION
The push refers to repository XXX
259e01ab73a94f2: Preparing
1eb06ab2fbfa: Waiting
26974475775146a: Retrying in 5 seconds
Double-check the permissions of service role. Make sure we it has this statement.
{
“Action”: [
“ecr:BatchCheckLayerAvailability”,
“ecr:CompleteLayerUpload”,
“ecr:GetAuthorizationToken”,
“ecr:InitiateLayerUpload”,
“ecr:PutImage”,
“ecr:UploadLayerPart”
],
“Resource”: “*”,
“Effect”: “Allow”
}
Build to s3 but deploy failed?Double-check the source artifact as the output of codebuild and the input of codedeploy.
DOWNLOAD_SOURCE issue …i/o timeout for primary source and source version…I was totally wrong about the “source” config for codebuild. I had set “codecommit” as the source. But in fact, that must be codepipeline.

Source provider
AWS CodePipeline
Source identifier

Repository

Source version
arn:aws:s3:::codepipeline-ap-southeast-1-534300658303/wito-frontend/SourceArti/RADEzjl
Git clone depth
Full
Git submodules
False
Codedeploy keeps starting deploying task forever?Should install awslog for getting log into clouldwatch to see what happend.
Check this out.
{ “containerDefinitions”: [ { “logConfiguration”: { “logDriver”: “awslogs”, “options”: { “awslogs-group”: “firelens-container”, “awslogs-region”: “us-west-2”, “awslogs-create-group”: “true”, “awslogs-stream-prefix”: “firelens” } } }

exec /usr/local/bin/docker-entrypoint.sh: exec format error
This is about the architecture issue.
-We used mac M1 apple silicon to develop this project. So there might be some configs in source code.
-We created the codebuild project which using linux/amd64 instance type to build our mac M1 project.
Solution: I found there are many people tell that we should to below:
-add this environment variable DOCKER_DEFAULT_PLATFORM: ‘linux/amd64’;
-change dockerfile: FROM –platform=linux/amd64 node:16.17

I tried all those things and found it does not work. So I changed the instance type of codebuild project from amd to arm and the build is successful.
If your team has people to use both two types amd and arm. So you need to create two codebuild project for each one.

Update: can use –platform linux/amd64 while building image for pushing to repository.
docker build –platform linux/amd64 -t willnguyen/auth auth
Can not deploy image to ecs.There might be many reason. Let’s check your images in the repository. One important thing is the task definition. We must add the container image with “:latest” tag. So codepipeline will auto create new revision once new container image built, and redeploy the ecs service tasks.

Mac Apple Silicon M1 Issue

Adding –platform linux/amd64 right after “build”. Don’t put it after image name, cuz after image name are parameters for image.

docker build --platform linux/amd64 -t willnguyen/auth auth
0