Skip to content

Deploy Lambda - Obtener datos y publica en tópico SNS #1

Deploy Lambda - Obtener datos y publica en tópico SNS

Deploy Lambda - Obtener datos y publica en tópico SNS #1

name: Deploy Lambda - Obtener datos y publica en tópico SNS
on:
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
env:
DOCKER_REPO: guillevalin/app-getandpublish
LAMBDA_IMAGE_TAG: "latest"
run: |
cd app-getandpublish
docker build -t $DOCKER_REPO:$LAMBDA_IMAGE_TAG .
docker push $DOCKER_REPO:$LAMBDA_IMAGE_TAG
- name: Set up AWS CLI
uses: aws-actions/configure-aws-credentials@v1
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: "us-east-1"
- name: Deploy to AWS Lambda
env:
LAMBDA_FUNCTION_NAME: "app-getandpublish"
LAMBDA_ROLE: ${{ secrets.LAMBDA_ROLE }}
DOCKER_REPO_URI: "guillevalin/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