Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

AWS ECS deploy not updating new revision and not updating latest image from ecr

Venkat P September 8, 2023

Hi Team,

We are using below script to deploying the AWS ECS, it's trying to updating ecs service but not updating and it's sitting old revision and ecr latest image also not updating can some one suggest how to deploy aws ecs using bitbucket pipeline.

Mentioned below yml file.

 

image: python:3.7.4-alpine3.10
pipelines:
tags:
ecr-release-*:
- step:
name: Build and pushing the Docker Image
services:
- docker
caches:
- pip
script:
- pip3 install awscli
- IMAGE="709724358365.dkr.ecr.ap-south-1.amazonaws.com/testrepo"
- TAG=V1.1.05
- aws configure set aws_access_key_id $AWS_ACCESS_KEY
- aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
- aws configure set AWS_DEFAULT_REGION $AWS_REGION
- eval $(aws ecr get-login --no-include-email --region ap-south-1 | sed 's;https://;;g')
- docker build -t $IMAGE:$TAG .
- docker push $IMAGE:$TAG
- step:
name: Deploy to ECS
script:
- pipe: atlassian/aws-ecs-deploy:1.8.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_REGION
CLUSTER_NAME: 'myapp-cluster'
SERVICE_NAME: 'testapp-service'
TASK_DEFINITION: 'task-definition.json'
FORCE_NEW_DEPLOYMENT: 'true'

1 answer

0 votes
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 8, 2023

@Venkat P  Thanks for your question. Please, take a look at this answer.

Regards, Igor

Venkat P September 8, 2023

Thanks for you answer Igor,

still I'm getting below error, I have mentioned my yml file below can you please suggest anything need to add?

 

Error:  Docker push error: EOF

 

image: python:3.7.4-alpine3.10
pipelines:
tags:
ecr-release-*:
- step:
name: build & push the docker image
services:
- docker
caches:
- pip
oidc: true
script:
# build the image
- pip3 install awscli
- IMAGE="709724358365.dkr.ecr.ap-south-1.amazonaws.com/testrepo"
- TAG=latest
- aws configure set aws_access_key_id $AWS_ACCESS_KEY
- aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
- aws configure set AWS_DEFAULT_REGION $AWS_REGION
- eval $(aws ecr get-login --no-include-email --region ap-south-1 | sed 's;https://;;g')
- docker build -t my-docker-image .

# use the pipe to push the image to AWS ECR
- pipe: atlassian/aws-ecr-push-image:1.5.0
variables:
AWS_DEFAULT_REGION: $AWS_REGION
IMAGE: $IMAGE
TAG: $TAG
AWS_OIDC_ROLE_ARN: 'arn:aws:iam::709724358365:role/ecsdeployrole'
IMAGE_NAME: my-docker-image
- step:
oidc: true
script:

- pipe: atlassian/aws-ecs-deploy:1.6.2
variables:
AWS_DEFAULT_REGION: $AWS_REGION
AWS_OIDC_ROLE_ARN: 'arn:aws:iam::709724358365:role/ecsdeployrole'
CLUSTER_NAME: 'myappcluster'
SERVICE_NAME: 'testapp-service'
TASK_DEFINITION: 'task-definition.json'

Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 8, 2023

@Venkat P . I think this is not necessary:
"""
- pip3 install awscli
- IMAGE="709724358365.dkr.ecr.ap-south-1.amazonaws.com/testrepo"
- TAG=latest
- aws configure set aws_access_key_id $AWS_ACCESS_KEY
- aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
- aws configure set AWS_DEFAULT_REGION $AWS_REGION
- eval $(aws ecr get-login --no-include-email --region ap-south-1 | sed 's;https://;;g')
"""


Just: 

"""

- docker build -t my-docker-image .

# use the pipe to push the image to AWS ECR
- pipe: atlassian/aws-ecr-push-image:1.5.0
... and so on
"""


According to your error: 
Error: Docker push error: EOF , seems like you don't have ECR repository, check prerequisites in aws-ecr-push-image pipe

Regards, Igor


Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 8, 2023

@Venkat P some info. If you had setup AWS_ACCESS_KEY, AWS_SECRET_ACCESS_KEY, AWS_REGION as Repository variables, the pipe will automatically use them according to: https://bitbucket.org/atlassian/aws-ecr-push-image/src/12710693b00ae7438763a360359d5b41b3de0135/pipe.yml#lines-6

Regards, Igor

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events