Skip to content

Deploy Terraform

Deploy Terraform #687

#
# Nimbus
# Terraform
# Deploy Pipeline
#
name: "Deploy Terraform"
on:
workflow_dispatch:
inputs:
# WARP VM inputs
# setting: whether to deploy the warp vm
deploy_warp_vm:
type: boolean
description: "WARP VM: Deploy?"
default: false
required: true
# list of comma separate ports to open on warp vm for development purposes
warp_vm_allow_ports:
type: string
description: "WARP VM: Comma-separated ports to expose"
required: false
default: ""
# warp vm machine type setting to control cpu, ram & cost of deployed vm
warp_vm_machine_type:
type: choice
description: "WARM VM: Machine Type (CPU & RAM)"
required: true
default: "e2-standard-2 - 2CPU, 8GB"
options:
- "e2-micro - 0.25CPU, 1GB"
- "e2-small - 0.5CPU, 2GB"
- "e2-medium - 1CPU, 4GB"
- "e2-standard-2 - 2CPU, 8GB"
- "e2-standard-4 - 4CPU, 16GB"
- "e2-standard-8 - 8CPU, 32GB"
# set vm image used to start warp vm
warp_vm_image:
type: string
description: "WARP VM: Boot Image"
required: true
default: "warp-box"
# whether to enable warp vm's http web terminal
warp_vm_http_term:
type: boolean
description: "WARP VM: Publicly accessible Web Terminal (HTTP)?"
required: true
default: false
# ip range to allow traffic to warp VM for security
warp_vm_allow_ip:
type: string
description: "WARP VM: Allow traffic from IPs (CIDR range):"
required: true
# by default, allow traffic from all ip addresses
default: "0.0.0.0/0"
jobs:
apply-terraform:
name: "Apply Terraform deployment"
runs-on: ubuntu-20.04
defaults:
run:
working-directory: terraform
steps:
- uses: actions/checkout@v3
- name: "Setup Terraform CLI"
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.9.3
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: "Terraform Init"
run: terraform init
- name: "Terraform Apply"
if: ${{ github.ref == 'refs/heads/main' }}
env:
TF_VAR_has_warp_vm: "${{ github.event.inputs.deploy_warp_vm }}"
TF_VAR_warp_image: "${{ github.event.inputs.warp_vm_image }}"
TF_VAR_warp_allow_ports: "${{ github.event.inputs.warp_vm_allow_ports }}"
TF_VAR_warp_http_terminal: "${{ github.event.inputs.warp_vm_http_term }}"
TF_VAR_warp_allow_ip: "${{ github.event.inputs.warp_vm_allow_ip }}"
run: >
terraform apply
-auto-approve=true
-var="warp_machine_type=$(
echo '${{ github.event.inputs.warp_vm_machine_type }}' | cut -d ' ' -f 1 -n
)"