mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-30 13:10:56 +00:00
script to make terraform deploy
This commit is contained in:
parent
29c1deca7c
commit
9204074eb8
3 changed files with 86 additions and 79 deletions
41
.github/workflows/actions/lambda/action.yml
vendored
41
.github/workflows/actions/lambda/action.yml
vendored
|
|
@ -1,7 +1,40 @@
|
|||
name: "Lambda Shared Action"
|
||||
description: "Common setup for Lambda jobs"
|
||||
name: "Build and Push Lambda Image to ECR"
|
||||
description: "Reusable action for building and pushing lambda Docker image to ECR"
|
||||
|
||||
inputs:
|
||||
lambda_name:
|
||||
description: "Lambda name / ECR repo name"
|
||||
required: true
|
||||
dockerfile_path:
|
||||
description: "Path to Dockerfile"
|
||||
required: true
|
||||
aws_region:
|
||||
description: "AWS region"
|
||||
required: false
|
||||
default: "eu-west-2"
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- run: echo "This is the lambda shared action"
|
||||
shell: bash
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Configure AWS credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
aws-region: ${{ inputs.aws_region }}
|
||||
|
||||
- name: Log in to Amazon ECR
|
||||
id: login-ecr
|
||||
uses: aws-actions/amazon-ecr-login@v2
|
||||
|
||||
- name: Build and push Docker image
|
||||
shell: bash
|
||||
run: |
|
||||
IMAGE_URI=${{ steps.login-ecr.outputs.registry }}/${{ inputs.lambda_name }}:latest
|
||||
echo "Building Docker image for ${{ inputs.lambda_name }}..."
|
||||
docker build -t $IMAGE_URI -f ${{ inputs.dockerfile_path }} .
|
||||
|
||||
echo "Pushing to ECR..."
|
||||
docker push $IMAGE_URI
|
||||
|
|
|
|||
30
.github/workflows/actions/terraform-deploy/action.yml
vendored
Normal file
30
.github/workflows/actions/terraform-deploy/action.yml
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
name: "Terraform Plan Shared Config"
|
||||
description: "Plans shared Terraform config for Lambdas"
|
||||
|
||||
inputs:
|
||||
working_directory:
|
||||
description: "Directory containing Terraform config"
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Terraform
|
||||
uses: hashicorp/setup-terraform@v3
|
||||
|
||||
- name: Terraform Init
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
shell: bash
|
||||
run: terraform init -reconfigure
|
||||
|
||||
- name: Terraform Plan
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
shell: bash
|
||||
run: terraform plan -out=tfplan
|
||||
|
||||
- name: Terraform Apply
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
shell: bash
|
||||
run: terraform apply -auto-approve tfplan
|
||||
94
.github/workflows/lambda_main.yml
vendored
94
.github/workflows/lambda_main.yml
vendored
|
|
@ -1,91 +1,35 @@
|
|||
name: Script to deploy lambdas to aws
|
||||
name: Lambda Main Workflow
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [feature/seperate_terraform_with_different_states, main]
|
||||
branches: [main, feature/seperate_terraform_with_different_states]
|
||||
|
||||
env:
|
||||
AWS_REGION: eu-west-2
|
||||
|
||||
jobs:
|
||||
build-and-push-to-ecr-for-lambda-example:
|
||||
lambda-ecr-example:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
ECR_REPOSITORY: lambda_example
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Run lambda shared action
|
||||
uses: ./.github/workflows/actions/lambda
|
||||
- name: Build and deploy Lambda example
|
||||
uses: ./.github/actions/lambda-deploy
|
||||
with:
|
||||
lambda_name: lambda_example
|
||||
dockerfile_path: deployment/lambda/lambda_example/docker/Dockerfile
|
||||
|
||||
# - name: AWS credentials
|
||||
# uses: aws-actions/configure-aws-credentials@v4
|
||||
# with:
|
||||
# # as of 14/07/2025 it'll be using user:Junte's keys
|
||||
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
# aws-region: ${{ secrets.AWS_REGION }}
|
||||
extractor-and-loader:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
|
||||
# - name: Log in to Amazon ECR
|
||||
# id: login-ecr
|
||||
# uses: aws-actions/amazon-ecr-login@v2
|
||||
|
||||
# - name: Build, tag, and push Docker image to ECR
|
||||
# env:
|
||||
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
||||
# IMAGE_TAG: latest
|
||||
# run: |
|
||||
# IMAGE_URI=${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
|
||||
# echo "pwd"
|
||||
# pwd
|
||||
# ls -la
|
||||
# echo "Building Docker image..."
|
||||
# docker build -t $IMAGE_URI -f deployment/lambda/lambda_example/docker/Dockerfile .
|
||||
|
||||
# echo "Pushing Docker image to ECR..."
|
||||
# docker push $IMAGE_URI
|
||||
|
||||
# build-and-push-to-ecr-for-extractor-and-loader-example:
|
||||
# runs-on: ubuntu-latest
|
||||
# env:
|
||||
# ECR_REPOSITORY: extractor_and_loader
|
||||
|
||||
# permissions:
|
||||
# id-token: write
|
||||
# contents: read
|
||||
|
||||
# steps:
|
||||
# - name: Checkout code
|
||||
# uses: actions/checkout@v4
|
||||
|
||||
# - name: AWS credentials
|
||||
# uses: aws-actions/configure-aws-credentials@v4
|
||||
# with:
|
||||
# # as of 14/07/2025 it'll be using user:Junte's keys
|
||||
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
# aws-region: ${{ secrets.AWS_REGION }}
|
||||
|
||||
# - name: Log in to Amazon ECR
|
||||
# id: login-ecr
|
||||
# uses: aws-actions/amazon-ecr-login@v2
|
||||
|
||||
# - name: Build, tag, and push Docker image to ECR
|
||||
# env:
|
||||
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
||||
# IMAGE_TAG: latest
|
||||
# run: |
|
||||
# IMAGE_URI=${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
|
||||
# echo "pwd"
|
||||
# pwd
|
||||
# ls -la
|
||||
# echo "Building Docker image..."
|
||||
# docker build -t $IMAGE_URI -f deployment/lambda/extractor_and_loader/docker/Dockerfile .
|
||||
|
||||
# echo "Pushing Docker image to ECR..."
|
||||
# docker push $IMAGE_URI
|
||||
steps:
|
||||
- name: Build and deploy Extractor & Loader Lambda
|
||||
uses: ./.github/actions/lambda-deploy
|
||||
with:
|
||||
lambda_name: extractor_and_loader
|
||||
dockerfile_path: deployment/lambda/extractor_and_loader/docker/Dockerfile
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue