Adding VPC with subnet and redirect traffic from EC2 instance into a … #25
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: 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 Plan | |
run: terraform plan -out=tfplan | |
working-directory: terraform | |
- name: Terraform Apply | |
run: terraform apply -auto-approve tfplan | |
working-directory: terraform | |
# - 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" | |