From 09c4d5f64ccd597f80f260dbe2741ac4d4a274cc Mon Sep 17 00:00:00 2001 From: gatici Date: Mon, 5 Feb 2024 15:36:23 +0300 Subject: [PATCH] Add the Github workflow for the Terraform checks Signed-off-by: gatici --- .github/workflows/terraform.yaml | 30 ++++++++++++++++++++++++++++++ terraform/README.md | 6 +++--- terraform/terraform.tf | 2 +- terraform/variables.tf | 2 +- 4 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/terraform.yaml diff --git a/.github/workflows/terraform.yaml b/.github/workflows/terraform.yaml new file mode 100644 index 000000000..f161c7126 --- /dev/null +++ b/.github/workflows/terraform.yaml @@ -0,0 +1,30 @@ +name: Check the Terraform Module + +on: + pull_request: + paths: + - '**.tf' + +jobs: + build: + name: Terraform Checks and Plans + runs-on: ubuntu-latest + steps: + - name: Checkout the repository to the runner + uses: actions/checkout@v3 + + - name: HashiCorp - Setup Terraform + uses: hashicorp/setup-terraform@v3 + + - name: Terraform Format + id: fmt + run: terraform fmt -recursive -check + continue-on-error: true + + - name: Terraform Init + id: init + run: terraform init + + - name: Terraform Validate + id: validate + run: terraform validate -no-color \ No newline at end of file diff --git a/terraform/README.md b/terraform/README.md index 98f78129b..22496704d 100644 --- a/terraform/README.md +++ b/terraform/README.md @@ -41,13 +41,13 @@ Replace the values in the `terraform.tfvars` file: model_name = "put your model-name here" ``` -Run Terraform Plan by providing var-file: +Create the Terraform Plan: ```console terraform plan -var-file="terraform.tfvars" ``` -Deploy the resources, skip the approval: +Deploy the resources by skipping the approval: ```console terraform apply -auto-approve @@ -63,7 +63,7 @@ juju status ### Clean up -Remove the application: +Destroy the deployment: ```console terraform destroy -auto-approve diff --git a/terraform/terraform.tf b/terraform/terraform.tf index 545a7bb57..4f60bb46b 100644 --- a/terraform/terraform.tf +++ b/terraform/terraform.tf @@ -1,4 +1,4 @@ -# Copyright 2023 Canonical Ltd. +# Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. terraform { diff --git a/terraform/variables.tf b/terraform/variables.tf index 4794f1702..6d8070bc5 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -5,7 +5,7 @@ variable "model_name" { } variable "channel" { - description = "The channel to use when deploying a charm " + description = "The channel to use when deploying a charm" type = string default = "6/beta" }