Skip to content

Terraform EC2 instance with Milvus #10

Terraform EC2 instance with Milvus

Terraform EC2 instance with Milvus #10

name: Terraform Deployment and Post-Configuration
on:
push:
branches:
- main
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.SSH_PRIVATE_KEY }}" > "$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 Plan
run: terraform plan -out=tfplan
working-directory: terraform
- name: Terraform Apply
run: terraform apply -auto-approve tfplan
working-directory: terraform
- name: Set EC2 IP
run: |
echo "EC2_INSTANCE_IP=$(terraform output -raw ec2_instance_public_ip)" >> $GITHUB_ENV
working-directory: terraform
- 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"