Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kolosovpetro committed Sep 1, 2023
0 parents commit 7a00012
Show file tree
Hide file tree
Showing 26 changed files with 1,129 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .config/terraform-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
formatter: "markdown"

settings:
anchor: false
lockfile: false

output:
file: "README.md"

sections:
hide: [requirements]

content: |-
{{ .Providers }}
{{ .Modules }}
{{ .Resources }}
{{ .Inputs }}
{{ .Outputs }}
...
66 changes: 66 additions & 0 deletions .config/tflint.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
plugin "azurerm" {
enabled = true
source = "github.com/terraform-linters/tflint-ruleset-azurerm"
version = "0.21.0"
}

config {
module = true
force = false
disabled_by_default = false

varfile = ["terraform.tfvars.ci"]
}

rule "terraform_deprecated_interpolation" {
enabled = true
}

rule "terraform_deprecated_index" {
enabled = true
}

rule "terraform_unused_declarations" {
enabled = true
}

rule "terraform_comment_syntax" {
enabled = true
}

rule "terraform_documented_outputs" {
enabled = true
}

rule "terraform_documented_variables" {
enabled = true
}

rule "terraform_typed_variables" {
enabled = true
}

rule "terraform_module_pinned_source" {
enabled = true
}

rule "terraform_naming_convention" {
enabled = true
}

rule "terraform_required_version" {
enabled = true
}

rule "terraform_required_providers" {
enabled = true
}

rule "terraform_unused_required_providers" {
enabled = true
}

# Disabled since we have files like "variables-xxxx.tf" instead of a single "variables.tf"
rule "terraform_standard_module_structure" {
enabled = false
}
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto eol=lf
*.html linguist-detectable=false
*.cshtml linguist-detectable=false
*.htm linguist-detectable=false
*.razor linguist-detectable=false
66 changes: 66 additions & 0 deletions .github/workflows/terraform-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Validate Terraform

on:
push:
branches:
- master
- main
- develop

pull_request:
branches:
- master
- main
- develop

workflow_dispatch:

# schedule:
# - cron: '0 0 * * 0'

jobs:
build-webapp:
name: Validate Terraform
runs-on: ${{ matrix.environment }}
strategy:
matrix:
environment:
- ubuntu-latest

env:
DOTNET_NOLOGO: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
ACTIONS_RUNNER_DEBUG: true
TF_LOG: INFO
ARM_CLIENT_ID: ""
ARM_CLIENT_SECRET: ${{ secrets.TF_ARM_CLIENT_SECRET }}
ARM_SUBSCRIPTION_ID: ""
ARM_TENANT_ID: ""
WORKING_DIR: "./"

steps:
- name: Fetch Sources
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: latest

- name: Terraform Version
run: terraform -v
working-directory: ${{ env.WORKING_DIR }}

- name: Terraform Init
run: terraform init -backend=false
working-directory: ${{ env.WORKING_DIR }}

- name: Terraform Validate
run: terraform validate
working-directory: ${{ env.WORKING_DIR }}

- name: Terraform Format
run: terraform fmt -check
working-directory: ${{ env.WORKING_DIR }}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.idea
.ssh
*.conf
.terraform
*.tfplan
*.tfstate
*.lock.info
*.tfstate.backup
*.lock.hcl
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: check-yaml
args:
- --unsafe
- id: check-symlinks
- id: check-added-large-files
- id: detect-private-key

- repo: https://github.com/antonbabenko/pre-commit-terraform.git
rev: v1.77.1
hooks:
- id: terraform_fmt
- id: terraform_docs
args:
- --hook-config=--path-to-file=README.md
- --hook-config=--add-to-existing-file=true
- --hook-config=--create-file-if-not-exist=true
exclude: '^modules|^example|^tools'
- id: terraform_validate
exclude: '^examples|^modules'

- id: terraform_tflint
exclude: '^examples'
args:
- --args=--config=__GIT_WORKING_DIR__/.config/tflint.hcl
- --env-vars=TFLINT_LOG="info"
Loading

0 comments on commit 7a00012

Please sign in to comment.