-
Notifications
You must be signed in to change notification settings - Fork 0
Create terraform.yml #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| - name: Terraform Init | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| provider "google" { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 {} | ||
| } | ||
| } | ||
There was a problem hiding this comment.
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