Deploy Lambda - Obtener datos y publica en tópico SNS #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Lambda - Obtener datos y publica en tópico SNS | |
on: | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone repository | |
run: | | |
git clone https://github.com/guillevalin/devops-challenge.git | |
cd devops-challenge | |
- name: Set up Docker Buildx | |
run: | | |
docker buildx create --use | |
- name: Configure AWS CLI | |
run: | | |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws configure set region us-east-1 | |
- name: Build and push Docker image | |
env: | |
DOCKER_REPO: 296062555964.dkr.ecr.us-east-1.amazonaws.com/app-getandpublish | |
LAMBDA_IMAGE_TAG: "latest" | |
run: | | |
cd devops-challenge/app-getandpublish | |
aws ecr get-login-password --region us-east-1 | docker login -u AWS --password-stdin 296062555964.dkr.ecr.us-east-1.amazonaws.com | |
docker build -t $DOCKER_REPO:$LAMBDA_IMAGE_TAG . | |
docker push $DOCKER_REPO:$LAMBDA_IMAGE_TAG | |
- name: Deploy to AWS Lambda | |
env: | |
LAMBDA_FUNCTION_NAME: "app-getandpublish" | |
LAMBDA_ROLE: ${{ secrets.LAMBDA_ROLE }} | |
DOCKER_REPO_URI: "296062555964.dkr.ecr.us-east-1.amazonaws.com/app-getandpublish:latest" | |
run: | | |
aws lambda create-function \ | |
--function-name $LAMBDA_FUNCTION_NAME \ | |
--package-type Image \ | |
--code ImageUri=$DOCKER_REPO_URI \ | |
--role $LAMBDA_ROLE \ | |
--region us-east-1 \ | |
|| aws lambda update-function-code \ | |
--function-name $LAMBDA_FUNCTION_NAME \ | |
--image-uri $DOCKER_REPO_URI \ | |
--region us-east-1 |