-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: 'Verify Terraform syntax' | ||
|
||
on: | ||
# Triggers the workflow on push or pull request events but only for default and protected branches | ||
push: | ||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
actions: read | ||
id-token: write # Required for Octo STS | ||
|
||
jobs: | ||
terraform_check: | ||
name: 'Check ${{matrix.directory}} directory' | ||
runs-on: [ubuntu-latest] | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
directory: [test] | ||
|
||
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
|
||
steps: | ||
- uses: octo-sts/action@6177b4481c00308b3839969c3eca88c96a91775f # v1.0.0 | ||
id: octo-sts | ||
with: | ||
scope: kartverket/terraform-modules | ||
identity: kartverket_repos | ||
|
||
# Checkout the repository to the GitHub Actions runner | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ steps.octo-sts.outputs.token }} | ||
|
||
- name: hack for github internal repo access | ||
run: git config --global url."https://x-access-token:${{ secrets.GITHUB_SECRET }}@github.com".insteadOf ssh://git@github.com | ||
|
||
# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token | ||
- name: Setup Terraform | ||
uses: hashicorp/setup-terraform@v3 | ||
with: | ||
terraform_wrapper: false | ||
terraform_version: 1.6.6 | ||
|
||
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc. | ||
- name: Terraform Init | ||
working-directory: ${{matrix.directory}} | ||
run: terraform init -backend=false | ||
|
||
# Checks that all Terraform configuration files adhere to a canonical format | ||
- name: Terraform Format | ||
working-directory: ${{matrix.directory}} | ||
run: terraform validate | ||
|
||
# Checks that all Terraform configuration files adhere to a canonical format | ||
- name: Terraform Format | ||
working-directory: ${{matrix.directory}} | ||
run: | | ||
terraform fmt -check || { echo ' | ||
FAILURE! The above files are not properly formatted. | ||
Run `terraform fmt` in the ${{matrix.directory}} directory, commit the changed files and push to fix the issue' >&2; exit 1; } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module "cloudsql_test" { | ||
source = "git@github.com:kartverket/terraform-modules.git/?ref=cloud_sql/0.1.0" | ||
env = "sandbox" | ||
instance_name = "test2" | ||
project_id = "skip-sandbox-37c2" | ||
iam_users = { | ||
some-user = { | ||
app_namespace = "foo-main" | ||
app_name = "some-api-backend" | ||
}, | ||
} | ||
} | ||
|
||
terraform { | ||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = "6.3.0" | ||
} | ||
} | ||
} | ||
|
||
provider "google" { | ||
region = "europe-north1" | ||
} |