Skip to content

Delete bucket, policy, ALB and role, try again #70

Delete bucket, policy, ALB and role, try again

Delete bucket, policy, ALB and role, try again #70

name: Terraform Deployment and Post-Configuration
on:
push:
branches:
- feature/api
jobs:
terraform-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Configure AWS Credentials
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: Setup SSH Key
run: |
SSH_KEY_PATH=$(mktemp)
echo "${{ secrets.EC2_KEY_PAIR_NAME }}" > "$SSH_KEY_PATH"
chmod 600 "$SSH_KEY_PATH"
echo "SSH_KEY_PATH=${SSH_KEY_PATH}" >> $GITHUB_ENV
- name: Set up Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: "1.0.0"
- name: Initialize Terraform
run: terraform init
working-directory: terraform
- name: Terraform Refresh
run: terraform refresh
working-directory: terraform
- name: Terraform Plan
run: terraform plan -out=tfplan
working-directory: terraform
- name: Terraform Apply
run: terraform apply -auto-approve tfplan
working-directory: terraform
# env:
# TF_LOG: DEBUG
# - name: Set EC2_INSTANCE_IP environment variable
# run: |
# set -x
# EC2_INSTANCE_IP=$(terraform output -raw ec2_instance_public_ip)
# echo "EC2_INSTANCE_IP=$EC2_INSTANCE_IP" >> $GITHUB_ENV
# - name: Transfer create-milvus.sh to EC2 instance
# run: |
# scp -o StrictHostKeyChecking=no -i $SSH_KEY_PATH ./create-milvus.sh ubuntu@${{ env.EC2_INSTANCE_IP }}:/tmp/create-milvus.sh
# working-directory: terraform
# - name: Execute create-milvus.sh on EC2 instance
# run: |
# ssh -o StrictHostKeyChecking=no -i $SSH_KEY_PATH ubuntu@${{ env.EC2_INSTANCE_IP }} "bash /tmp/create-milvus.sh"
### DEPLOY MILVUS WITH CI CD:
# name: Deploy Milvus on EC2 Instance
# on:
# push:
# branches:
# - feature/testing
# workflow_dispatch:
# jobs:
# deploy:
# runs-on: ubuntu-latest
# steps:
# - name: Deploy to EC2
# env:
# SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
# HOSTNAME: ${{ secrets.SSH_HOST }}
# USERNAME: ${{ secrets.USERNAME }}
# PROJECT_DIRECTORY: ${{ secrets.PROJECT_DIRECTORY }}
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# run: |
# set -e
# echo "$SSH_PRIVATE_KEY" > private_key && chmod 600 private_key
# ssh -o StrictHostKeyChecking=no -i private_key ${USERNAME}@${HOSTNAME} "
# ps -ax | grep "[s]treamlit" | awk '{print $1}' | grep '^[0-9]*$' | xargs -r kill -9 &&
# sed -i 's|AWS_ACCESS_KEY_ID_PLACEHOLDER|${AWS_ACCESS_KEY_ID}|' start_app.sh &&
# sed -i 's|AWS_SECRET_ACCESS_KEY_PLACEHOLDER|${AWS_SECRET_ACCESS_KEY}|' start_app.sh &&
# ./start_app.sh
# "