Skip to content
name: Create Self Hosted Runner AMI
on:
push:
#paths:
#- self-hosted-runner.tf
jobs:
create-self-hosted-runner-ami:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: hashicorp/setup-terraform@v3
- name: Initialize Terraform Environment
run: |
terraform init
- name: Create PEM file
run: |
echo "${{ secrets.AWS_PEM_KEY }}" > ${{ secrets.AWS_KEY_NAME }}.pem
chmod 400 ${{ secrets.AWS_KEY_NAME }}.pem
- name: Apply Terraform Configuration
run: |
terraform apply -auto-approve -var=aws_access_key=${{ secrets.AWS_ACCESS_KEY_ID }} -var=aws_secret_key=${{ secrets.AWS_SECRET_ACCESS_KEY }} -var=aws_key_name=${{ secrets.AWS_KEY_NAME }}
- name: Destroy Terraform Configuration (should retain AMI from config)
run: |
terraform destroy -auto-approve -var=aws_access_key=${{ secrets.AWS_ACCESS_KEY_ID }} -var=aws_secret_key=${{ secrets.AWS_SECRET_ACCESS_KEY }} -var=aws_key_name=${{ secrets.AWS_KEY_NAME }}