Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: 'Terraform'

on:
push:
branches: [ "main" ]
pull_request:

permissions:
contents: read

jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
environment: production

defaults:
run:
shell: bash

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}

- name: 'Set up Google Cloud credentials'
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}

- name: 'Configure GCP Project'
run: gcloud config set project sit-23t1-project-echo-25288b9

- name: 'Configure GCP Region'
run: gcloud config set compute/region australia-southeast2

# No need to change directory since Terraform files are in the root directory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not a good check of the root modules if they aren't being checked

- name: Terraform Init
Copy link
Contributor

@theraginggoblin theraginggoblin Aug 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

terraform init is a good choice for a terraform ci check

run: terraform init

- name: Terraform Format
Copy link
Contributor

@theraginggoblin theraginggoblin Aug 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

terraform format checking is a good choice for a terraform ci check

run: terraform fmt -check

- name: Terraform Plan
run: terraform plan -input=false

- name: Terraform Apply
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apply should not be ran as a basic terraform ci check

if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: terraform apply -auto-approve -input=false
21 changes: 21 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
provider "google" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this file? doesn't appear necessary

project = "sit-23t1-project-echo-25288b9"
region = "australia-southeast2"
}

resource "google_compute_instance" "default" {
name = "simple-instance"
machine_type = "n1-standard-1"
zone = "australia-southeast2-a"

boot_disk {
initialize_params {
image = "debian-cloud/debian-9"
}
}

network_interface {
network = "default"
access_config {}
}
}