Merge pull request #1 from FloRul/dev #1
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: Apply infrastructure | |
on: | |
push: | |
branches: main | |
jobs: | |
apply: | |
defaults: | |
run: | |
working-directory: ${{ vars.TF_ACTIONS_WORKING_DIR }} | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: aws-actions/configure-aws-credentials@v2 | |
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: Setup Terraform | |
uses: hashicorp/setup-terraform@v3 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Get the latest ingestion image tag | |
id: get-latest-ingestion-tag | |
run: | | |
LATEST_INGESTION_TAG=$(aws ecr describe-images --repository-name ${{vars.INGESTION_LAMBDA_ECR}} --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' --output text) | |
echo "LATEST_INGESTION_TAG=$LATEST_INGESTION_TAG" >> $GITHUB_ENV | |
- name: Get the ingestion image URI from the build job | |
run: | | |
echo "INGESTION_IMAGE=${{ steps.login-ecr.outputs.registry }}/${{ vars.INGESTION_LAMBDA_ECR }}:${{env.LATEST_INGESTION_TAG}}" >> "$GITHUB_ENV" | |
- name: Get the latest memory image tag | |
id: get-latest-memory-tag | |
run: | | |
LATEST_MEMORY_TAG=$(aws ecr describe-images --repository-name ${{vars.MEMORY_LAMBDA_ECR}} --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' --output text) | |
echo "LATEST_MEMORY_TAG=$LATEST_MEMORY_TAG" >> $GITHUB_ENV | |
- name: Get the memory image URI from the build job | |
run: | | |
echo "MEMORY_IMAGE=${{ steps.login-ecr.outputs.registry }}/${{ vars.MEMORY_LAMBDA_ECR }}:${{env.LATEST_MEMORY_TAG}}" >> "$GITHUB_ENV" | |
- name: Get the latest inference image tag | |
id: get-latest-inference-tag | |
run: | | |
LATEST_INFERENCE_TAG=$(aws ecr describe-images --repository-name ${{vars.INFERENCE_LAMBDA_ECR}} --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' --output text) | |
echo "LATEST_INFERENCE_TAG=$LATEST_INFERENCE_TAG" >> $GITHUB_ENV | |
- name: Get the inference image URI from the build job | |
run: | | |
echo "INFERENCE_IMAGE=${{ steps.login-ecr.outputs.registry }}/${{ vars.INFERENCE_LAMBDA_ECR }}:${{env.LATEST_INFERENCE_TAG}}" >> "$GITHUB_ENV" | |
- name: Terraform Init | |
id: terraform-Init | |
run: | | |
terraform init -no-color -upgrade | |
- name: Terraform Apply | |
id: terraform-Apply | |
run: | | |
terraform apply -var="ingestion_lambda_image_uri=${{ env.INGESTION_IMAGE }}" -var="inference_lambda_image_uri=${{ env.INFERENCE_IMAGE }}" -var="memory_lambda_image_uri=${{ env.MEMORY_IMAGE }}" -no-color -auto-approve |