From 8901b313276f2c53adc257885498bd19b427c419 Mon Sep 17 00:00:00 2001 From: Vishal Sharma <83549768+vjdbj@users.noreply.github.com> Date: Thu, 28 Nov 2024 21:32:06 +0530 Subject: [PATCH] fix:remove deprecations (#30) * fix:remove deprecations * feat: upgrade module version to 4.9.0 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Deepak Verma --- .github/CODEOWNERS | 8 +- .github/dependabot.yml | 6 +- .github/workflows/auto_assignee.yml | 14 + .github/workflows/automerge.yml | 12 + .github/workflows/changelog.yml | 2 +- .github/workflows/readme.yml | 59 +- .github/workflows/semantic-releaser.yml | 30 - .github/workflows/static-checks.yml | 74 -- .github/workflows/tf-checks.yml | 24 + .github/workflows/tflint.yml | 11 + .github/workflows/tfsec.yml | 2 +- .pre-commit-config.yaml | 19 +- CHANGELOG.md | 2 +- LICENSE | 222 +----- README.md | 675 +++++++++++++----- README.yaml | 31 +- .../complete}/main.tf | 47 +- .../complete}/output.tf | 3 +- examples/complete/version.tf | 13 + .../point-to-site-with-certificate/main.tf | 45 +- .../point-to-site-with-certificate/output.tf | 3 +- .../point-to-site-with-certificate/version.tf | 13 + {example => examples}/site-to-site/main.tf | 75 +- {example => examples}/site-to-site/output.tf | 6 +- examples/site-to-site/version.tf | 13 + main.tf | 78 +- output.tf | 9 +- variables.tf | 128 +--- versions.tf | 4 + 29 files changed, 840 insertions(+), 788 deletions(-) create mode 100644 .github/workflows/auto_assignee.yml create mode 100644 .github/workflows/automerge.yml delete mode 100644 .github/workflows/semantic-releaser.yml delete mode 100644 .github/workflows/static-checks.yml create mode 100644 .github/workflows/tf-checks.yml create mode 100644 .github/workflows/tflint.yml rename {example/point-to-site-with-ad => examples/complete}/main.tf (68%) rename {example/point-to-site-with-ad => examples/complete}/output.tf (61%) create mode 100644 examples/complete/version.tf rename {example => examples}/point-to-site-with-certificate/main.tf (73%) rename {example => examples}/point-to-site-with-certificate/output.tf (56%) create mode 100644 examples/point-to-site-with-certificate/version.tf rename {example => examples}/site-to-site/main.tf (53%) rename {example => examples}/site-to-site/output.tf (61%) create mode 100644 examples/site-to-site/version.tf diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b30a2d4..c575e28 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,6 +1,2 @@ -.github/* @clouddrove/approvers - -* @clouddrove/clouddrovians @clouddrove/approvers - -.github/mergify.yml @clouddrove/admins -.github/CODEOWNERS @clouddrove/admins +# These owners will be the default owners for everything in the repo. +* @anmolnagpal @clouddrove-ci @clouddrove/terraform-azure-admins diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 812c152..1bb3c0f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -10,14 +10,14 @@ updates: schedule: interval: "weekly" - package-ecosystem: "terraform" # See documentation for possible values - directory: "example/point-to-site-with-ad" # Location of package manifests + directory: "examples/complete" # Location of package manifests schedule: interval: "weekly" - package-ecosystem: "terraform" # See documentation for possible values - directory: "example/point-to-site-with-certificate" # Location of package manifests + directory: "examples/point-to-site-with-certificate" # Location of package manifests schedule: interval: "weekly" - package-ecosystem: "terraform" # See documentation for possible values - directory: "example/site-to-site" # Location of package manifests + directory: "examples/site-to-site" # Location of package manifests schedule: interval: "weekly" diff --git a/.github/workflows/auto_assignee.yml b/.github/workflows/auto_assignee.yml new file mode 100644 index 0000000..f8b8bcd --- /dev/null +++ b/.github/workflows/auto_assignee.yml @@ -0,0 +1,14 @@ +name: Auto Assign PRs + +on: + pull_request: + types: [opened, reopened] + + workflow_dispatch: +jobs: + assignee: + uses: clouddrove/github-shared-workflows/.github/workflows/auto_assignee.yml@master + secrets: + GITHUB: ${{ secrets.GITHUB }} + with: + assignees: 'clouddrove-ci' diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 0000000..26392e2 --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,12 @@ +--- +name: Auto merge +on: + pull_request: +jobs: + auto-merge: + uses: clouddrove/github-shared-workflows/.github/workflows/auto_merge.yml@master + secrets: + GITHUB: ${{ secrets.GITHUB }} + with: + tfcheck: 'complete-example / Check code format' +... diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 3e88b85..8810fc4 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -10,4 +10,4 @@ jobs: uses: clouddrove/github-shared-workflows/.github/workflows/changelog.yml@master secrets: inherit with: - branch: 'master' \ No newline at end of file + branch: 'master' diff --git a/.github/workflows/readme.yml b/.github/workflows/readme.yml index 8b60bee..c4a5793 100644 --- a/.github/workflows/readme.yml +++ b/.github/workflows/readme.yml @@ -1,54 +1,15 @@ -name: 'Create README.md file' +name: Readme Workflow on: push: branches: - master - + paths-ignore: + - 'README.md' + - 'docs/**' + workflow_dispatch: jobs: - readme-create: - name: 'readme-create' - runs-on: ubuntu-latest - steps: - - name: 'Checkout' - uses: actions/checkout@master - - - name: 'Set up Python 3.7' - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - - name: 'create readme' - uses: 'clouddrove/github-actions@v9.0.2' - with: - actions_subcommand: 'readme' - github_token: '${{ secrets.GITHUB }}' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - - name: 'pre-commit check errors' - uses: pre-commit/action@v2.0.0 - continue-on-error: true - - - name: 'pre-commit fix erros' - uses: pre-commit/action@v2.0.0 - continue-on-error: true - - - name: 'push readme' - uses: 'clouddrove/github-actions@v9.0.2' - continue-on-error: true - with: - actions_subcommand: 'push' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: 'Slack Notification' - uses: clouddrove/action-slack@v2 - with: - status: ${{ job.status }} - fields: repo,author - author_name: 'CloudDrove' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required - if: always() + README: + uses: clouddrove/github-shared-workflows/.github/workflows/readme.yml@master + secrets: + TOKEN : ${{ secrets.GITHUB }} + SLACK_WEBHOOK_TERRAFORM: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} diff --git a/.github/workflows/semantic-releaser.yml b/.github/workflows/semantic-releaser.yml deleted file mode 100644 index 6e685a0..0000000 --- a/.github/workflows/semantic-releaser.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Release - -on: - push: - branches: - - main - paths: - - '**.tf' - - '!examples/**.tf' - -jobs: - release: - name: Release - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - persist-credentials: false - - - name: Setup Node.js - uses: actions/setup-node@v1 - with: - node-version: 14 - - - name: Release - env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - run: npx semantic-release diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml deleted file mode 100644 index 27cbe32..0000000 --- a/.github/workflows/static-checks.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: static-checks - -on: - pull_request: - -jobs: - versionExtract: - name: Get min/max versions - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Terraform min/max versions - id: minMax - uses: clowdhaus/terraform-min-max@main - outputs: - minVersion: ${{ steps.minMax.outputs.minVersion }} - maxVersion: ${{ steps.minMax.outputs.maxVersion }} - - versionEvaluate: - name: Evaluate Terraform versions - runs-on: ubuntu-latest - needs: versionExtract - strategy: - fail-fast: false - matrix: - version: - - ${{ needs.versionExtract.outputs.minVersion }} - - ${{ needs.versionExtract.outputs.maxVersion }} - directory: - - example/ - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install Terraform v${{ matrix.version }} - uses: hashicorp/setup-terraform@v1 - with: - terraform_version: ${{ matrix.version }} - - - name: Init & validate v${{ matrix.version }} - run: | - cd ${{ matrix.directory }} - terraform init - terraform validate - - name: tflint - uses: reviewdog/action-tflint@master - with: - tflint_version: v0.29.0 - github_token: ${{ secrets.GITHUB_TOKEN }} - working_directory: ${{ matrix.directory }} - fail_on_error: 'true' - filter_mode: 'nofilter' - flags: '--module' - - format: - name: Check code format - runs-on: ubuntu-latest - needs: versionExtract - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install Terraform v${{ needs.versionExtract.outputs.maxVersion }} - uses: hashicorp/setup-terraform@v1 - with: - terraform_version: ${{ needs.versionExtract.outputs.maxVersion }} - - - name: Check Terraform format changes - run: terraform fmt --recursive -check=true diff --git a/.github/workflows/tf-checks.yml b/.github/workflows/tf-checks.yml new file mode 100644 index 0000000..09cb95e --- /dev/null +++ b/.github/workflows/tf-checks.yml @@ -0,0 +1,24 @@ +name: tf-checks +on: + push: + branches: [ master ] + pull_request: + workflow_dispatch: +jobs: + site-to-site-example: + uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master + secrets: inherit + with: + working_directory: './examples/site-to-site/' + + complete-example: + uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master + secrets: inherit + with: + working_directory: './examples/complete/' + + point-to-site-with-certificate-example: + uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master + secrets: inherit + with: + working_directory: './examples/point-to-site-with-certificate/' diff --git a/.github/workflows/tflint.yml b/.github/workflows/tflint.yml new file mode 100644 index 0000000..71a6fc4 --- /dev/null +++ b/.github/workflows/tflint.yml @@ -0,0 +1,11 @@ +name: tf-lint +on: + push: + branches: [ master ] + pull_request: + workflow_dispatch: +jobs: + tf-lint: + uses: clouddrove/github-shared-workflows/.github/workflows/tf-lint.yml@master + secrets: + GITHUB: ${{ secrets.GITHUB }} diff --git a/.github/workflows/tfsec.yml b/.github/workflows/tfsec.yml index 9aaf588..c203751 100644 --- a/.github/workflows/tfsec.yml +++ b/.github/workflows/tfsec.yml @@ -8,4 +8,4 @@ jobs: uses: clouddrove/github-shared-workflows/.github/workflows/tfsec.yml@master secrets: inherit with: - working_directory: '.' \ No newline at end of file + working_directory: '.' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9e713a5..1e2f09f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,14 @@ +# repos: repos: - - - repo: https://github.com/gruntwork-io/pre-commit - rev: v0.1.12 # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases + - repo: https://github.com/antonbabenko/pre-commit-terraform + rev: v1.96.1 # Version of the pre-commit-terraform repository hooks: - - id: terraform-fmt - - id: shellcheck - - id: tflint + - id: terraform_fmt + - id: terraform_docs + - id: terraform_tflint - - repo: git://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 # Use the ref you want to point at + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 # Get the latest version from https://github.com/pre-commit/pre-commit-hooks/releases hooks: - id: end-of-file-fixer - id: trailing-whitespace @@ -16,6 +16,5 @@ repos: - id: check-byte-order-marker - id: check-executables-have-shebangs - id: check-merge-conflict - - id: debug-statements - - id: check-yaml - id: check-added-large-files + - id: check-yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f20fd5..0bfe737 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,4 +27,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [1.0.0]: https://github.com/clouddrove/terraform-azure-acr/compare/1.0.0...master [1.0.1]: https://github.com/clouddrove/terraform-azure-vpn/compare/1.0.0...1.0.1 -[1.0.2]: https://github.com/clouddrove/terraform-azure-vpn/compare/1.0.1...1.0.2 \ No newline at end of file +[1.0.2]: https://github.com/clouddrove/terraform-azure-vpn/compare/1.0.1...1.0.2 diff --git a/LICENSE b/LICENSE index 9579323..39327c9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,201 +1,21 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2021 CloudDrove Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +MIT License + +Copyright (c) 2018 The terraform-docs Authors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 31c87aa..093effc 100644 --- a/README.md +++ b/README.md @@ -1,262 +1,549 @@ - +# terraform-docs -

+[![Build Status](https://github.com/terraform-docs/terraform-docs/workflows/ci/badge.svg)](https://github.com/terraform-docs/terraform-docs/actions) [![GoDoc](https://pkg.go.dev/badge/github.com/terraform-docs/terraform-docs)](https://pkg.go.dev/github.com/terraform-docs/terraform-docs) [![Go Report Card](https://goreportcard.com/badge/github.com/terraform-docs/terraform-docs)](https://goreportcard.com/report/github.com/terraform-docs/terraform-docs) [![Codecov Report](https://codecov.io/gh/terraform-docs/terraform-docs/branch/master/graph/badge.svg)](https://codecov.io/gh/terraform-docs/terraform-docs) [![License](https://img.shields.io/github/license/terraform-docs/terraform-docs)](https://github.com/terraform-docs/terraform-docs/blob/master/LICENSE) [![Latest release](https://img.shields.io/github/v/release/terraform-docs/terraform-docs)](https://github.com/terraform-docs/terraform-docs/releases) +![terraform-docs-teaser](./images/terraform-docs-teaser.png) -

- Terraform AZURE VPN -

+Sponsored by [Scalr - Terraform Automation & Collaboration Software](https://scalr.com/?utm_source=terraform-docs) -

+<<<<<<< HEAD +

Terraform module to create vpn resource on AZURE.

+======= +Scalr - Terraform Automation & Collaboration Software +>>>>>>> 1dde4fa (fix: fixed pre-commits) -

+## What is terraform-docs - - Terraform - - - Licence - +A utility to generate documentation from Terraform modules in various output formats. +## Installation -

-

+macOS users can install using [Homebrew]: - - - - - - - - - +```bash +brew install terraform-docs +``` -

-
+or +```bash +brew install terraform-docs/tap/terraform-docs +``` -We eat, drink, sleep and most importantly love **DevOps**. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy Bigger problems are always solved by breaking them into smaller manageable problems. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller connected yet manageable pieces within the infrastructure. +<<<<<<< HEAD +We eat, drink, sleep and most importantly love **DevOps**. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy Bigger problems are always solved by breaking them into smaller manageable problems. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller connected yet manageable pieces within the infrastructure. +======= +Windows users can install using [Scoop]: +>>>>>>> 1dde4fa (fix: fixed pre-commits) -This module is basically combination of [Terraform open source](https://www.terraform.io/) and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself. +```bash +scoop bucket add terraform-docs https://github.com/terraform-docs/scoop-bucket +scoop install terraform-docs +``` -We have [*fifty plus terraform modules*][terraform_modules]. A few of them are comepleted and are available for open source usage while a few others are in progress. +or [Chocolatey]: +```bash +choco install terraform-docs +``` +Stable binaries are also available on the [releases] page. To install, download the +binary for your platform from "Assets" and place this into your `$PATH`: +```bash +curl -Lo ./terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/v0.16.0/terraform-docs-v0.16.0-$(uname)-amd64.tar.gz +tar -xzf terraform-docs.tar.gz +chmod +x terraform-docs +mv terraform-docs /usr/local/terraform-docs +``` -## Prerequisites +**NOTE:** Windows releases are in `ZIP` format. -This module has a few dependencies: +<<<<<<< HEAD +This module has a few dependencies: +======= +The latest version can be installed using `go install` or `go get`: +>>>>>>> 1dde4fa (fix: fixed pre-commits) -- [Terraform 1.x.x](https://learn.hashicorp.com/terraform/getting-started/install.html) -- [Go](https://golang.org/doc/install) -- [github.com/stretchr/testify/assert](https://github.com/stretchr/testify) -- [github.com/gruntwork-io/terratest/modules/terraform](https://github.com/gruntwork-io/terratest) +```bash +# go1.17+ +go install github.com/terraform-docs/terraform-docs@v0.16.0 +``` +```bash +# go1.16 +GO111MODULE="on" go get github.com/terraform-docs/terraform-docs@v0.16.0 +``` +**NOTE:** please use the latest Go to do this, minimum `go1.16` is required. +This will put `terraform-docs` in `$(go env GOPATH)/bin`. If you encounter the error +`terraform-docs: command not found` after installation then you may need to either add +that directory to your `$PATH` as shown [here] or do a manual installation by cloning +the repo and run `make build` from the repository which will put `terraform-docs` in: +```bash +$(go env GOPATH)/src/github.com/terraform-docs/terraform-docs/bin/$(uname | tr '[:upper:]' '[:lower:]')-amd64/terraform-docs +``` +## Usage +### Running the binary directly -## Examples +To run and generate documentation into README within a directory: +```bash +terraform-docs markdown table --output-file README.md --output-mode inject /path/to/module +``` -**IMPORTANT:** Since the `master` branch used in `source` varies based on new modifications, we suggest that you use the release versions [here](https://github.com/clouddrove/terraform-azure-vpn/releases). +Check [`output`] configuration for more details and examples. +### Using docker -Here are some examples of how you can use this module in your inventory structure: -### Default vnet-peering -```hcl - # vpn with azure ad - module "vpn" { - source = "clouddrove/vpn/azure" - version = "1.0.0" - depends_on = [module.vnet] - name = "app" - environment = "test" - label_order = ["name", "environment"] - vpn_ad = true - resource_group_name = module.resource_group.resource_group_name - virtual_network_name = module.vnet.vnet_name[0] - vpn_client_configuration = { - address_space = "172.16.200.0/24" - vpn_client_protocols = ["OpenVPN"] - vpn_auth_types = ["AAD"] - aad_tenant = "https://login.microsoftonline.com/bcffb719XXXXXXXXXXXX7ebfb2f7bdd" - aad_audience = "41b23e61-6c1e-4545-b367-cd054e0ed4b4" - aad_issuer = "https://sts.windows.net/bcffb719XXXXXXXXXXXX7ebfb2f7bdd/" - } - #### enable diagnostic setting - diagnostic_setting_enable = false - log_analytics_workspace_id = "" - } - ``` -```hcl -# vpn with certificate - module "vpn" { - source = "clouddrove/vpn/azure" - version = "1.0.0" - depends_on = [module.vnet] - name = "app" - environment = "test" - label_order = ["name", "environment"] - vpn_with_certificate = true - resource_group_name = module.resource_group.resource_group_name - virtual_network_name = module.vnet.vnet_name[0] - #### enable diagnostic setting - diagnostic_setting_enable = false - log_analytics_workspace_id = "" - vpn_client_configuration_c = { - address_space = "172.16.201.0/24" - vpn_client_protocols = ["OpenVPN", "IkeV2"] - certificate = < doc.md +``` + +**NOTE:** Docker tag `latest` refers to _latest_ stable released version and `edge` +refers to HEAD of `master` at any given point in time. + +### Using GitHub Actions + +To use terraform-docs GitHub Action, configure a YAML workflow file (e.g. +`.github/workflows/documentation.yml`) with the following: + +```yaml +name: Generate terraform docs +on: + - pull_request + +jobs: + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.ref }} + + - name: Render terraform docs and push changes back to PR + uses: terraform-docs/gh-actions@main + with: + working-dir: . + output-file: README.md + output-method: inject + git-push: "true" +``` + +Read more about [terraform-docs GitHub Action] and its configuration and +examples. - #### enable diagnostic setting - diagnostic_setting_enable = false - log_analytics_workspace_id = "" - local_networks = [ - { - local_gw_name = "app-test-onpremise" - local_gateway_address = "20.232.135.45" - local_address_space = ["30.1.0.0/16"] - shared_key = "xpCGkHTBQmDvZK9HnLr7DAvH" - }, - ] - } - ``` +### pre-commit hook +With pre-commit, you can ensure your Terraform module documentation is kept +up-to-date each time you make a commit. +First [install pre-commit] and then create or update a `.pre-commit-config.yaml` +in the root of your Git repo with at least the following content: +```yaml +repos: + - repo: https://github.com/terraform-docs/terraform-docs + rev: "v0.16.0" + hooks: + - id: terraform-docs-go + args: ["markdown", "table", "--output-file", "README.md", "./mymodule/path"] +``` + +Then run: + +```bash +pre-commit install +pre-commit install-hooks +``` + +Further changes to your module's `.tf` files will cause an update to documentation +when you make a commit. + +## Configuration + +terraform-docs can be configured with a yaml file. The default name of this file is +`.terraform-docs.yml` and the path order for locating it is: + +1. root of module directory +1. `.config/` folder at root of module directory +1. current directory +1. `.config/` folder at current directory +1. `$HOME/.tfdocs.d/` + +```yaml +formatter: "" # this is required + +version: "" + +header-from: main.tf +footer-from: "" +recursive: + enabled: false + path: modules +sections: + hide: [] + show: [] + +content: "" + +output: + file: "" + mode: inject + template: |- + +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 1.0.0 | +| [azurerm](#requirement\_azurerm) | >=3.0.0 | +| [random](#requirement\_random) | >= 3.1 | + +## Providers + +| Name | Version | +|------|---------| +| [azurerm](#provider\_azurerm) | >=3.0.0 | +| [random](#provider\_random) | >= 3.1 | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [labels](#module\_labels) | clouddrove/labels/azure | 1.0.0 | + +## Resources + +| Name | Type | +|------|------| +| [azurerm_local_network_gateway.localgw](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/local_network_gateway) | resource | +| [azurerm_monitor_diagnostic_setting.main](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_diagnostic_setting) | resource | +| [azurerm_monitor_diagnostic_setting.pip_gw](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_diagnostic_setting) | resource | +| [azurerm_public_ip.pip_gw](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip) | resource | +| [azurerm_virtual_network_gateway.vpngw](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network_gateway) | resource | +| [azurerm_virtual_network_gateway.vpngw2](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network_gateway) | resource | +| [azurerm_virtual_network_gateway_connection.az-hub-onprem](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network_gateway_connection) | resource | +| [random_string.str](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource | +| [azurerm_resource_group.rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) | data source | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| Metric\_enable | Is this Diagnostic Metric enabled? Defaults to true. | `bool` | `true` | no | -| app\_name | Name (e.g. `app` or `cluster`). | `string` | `""` | no | -| bgp\_asn\_number | The Autonomous System Number (ASN) to use as part of the BGP | `string` | `"65515"` | no | -| bgp\_peer\_weight | The weight added to routes which have been learned through BGP peering. Valid values can be between 0 and 100 | `string` | `""` | no | -| bgp\_peering\_address | The BGP peer IP address of the virtual network gateway. This address is needed to configure the created gateway as a BGP Peer on the on-premises VPN devices. The IP address must be part of the subnet of the Virtual Network Gateway. | `string` | `""` | no | -| category | The name of a Diagnostic Log Category Group for this Resource. | `string` | `null` | no | -| days | The number of days for which this Retention Policy should apply. | `number` | `"90"` | no | -| diagnostic\_setting\_enable | n/a | `bool` | `false` | no | -| enable | Flag to control module creation. | `bool` | `true` | no | -| enable\_active\_active | If true, an active-active Virtual Network Gateway will be created. An active-active gateway requires a HighPerformance or an UltraPerformance sku. If false, an active-standby gateway will be created. Defaults to false. | `bool` | `false` | no | -| enable\_bgp | If true, BGP (Border Gateway Protocol) will be enabled for this Virtual Network Gateway. Defaults to false | `bool` | `false` | no | -| environment | Environment (e.g. `prod`, `dev`, `staging`). | `string` | `""` | no | -| eventhub\_authorization\_rule\_id | Specifies the ID of an Event Hub Namespace Authorization Rule used to send Diagnostics Data. | `string` | `null` | no | -| eventhub\_name | Specifies the name of the Event Hub where Diagnostics Data should be sent. | `string` | `null` | no | -| express\_route\_circuit\_id | The ID of the Express Route Circuit when creating an ExpressRoute connection | `any` | `null` | no | -| expressroute\_sku | Configuration of the size and capacity of the virtual network gateway for ExpressRoute type. Valid options are Standard, HighPerformance, UltraPerformance, ErGw1AZ, ErGw2AZ, ErGw3AZ and depend on the type, vpn\_type and generation arguments | `string` | `"Standard"` | no | -| gateway\_connection\_protocol | The IKE protocol version to use. Possible values are IKEv1 and IKEv2. Defaults to IKEv2 | `string` | `"IKEv2"` | no | -| gateway\_connection\_type | The type of connection. Valid options are IPsec (Site-to-Site), ExpressRoute (ExpressRoute), and Vnet2Vnet (VNet-to-VNet) | `string` | `"IPsec"` | no | -| gateway\_type | The type of the Virtual Network Gateway. Valid options are Vpn or ExpressRoute | `string` | `"Vpn"` | no | -| label\_order | Label order, e.g. sequence of application name and environment `name`,`environment`,'attribute' [`webserver`,`qa`,`devops`,`public`,] . | `list(any)` |
[
"name",
"environment"
]
| no | -| local\_bgp\_settings | Local Network Gateway's BGP speaker settings | `list(object({ asn_number = number, peering_address = string, peer_weight = number }))` | `null` | no | -| local\_networks | List of local virtual network connections to connect to gateway | `list(object({ local_gw_name = string, local_gateway_address = string, local_address_space = list(string), shared_key = string }))` | `[]` | no | -| local\_networks\_ipsec\_policy | IPSec policy for local networks. Only a single policy can be defined for a connection. | `any` | `null` | no | -| location | The location/region to keep all your network resources. To get the list of all locations with table format from azure cli, run 'az account list-locations -o table' | `string` | `""` | no | -| log\_analytics\_destination\_type | Possible values are AzureDiagnostics and Dedicated, default to AzureDiagnostics. When set to Dedicated, logs sent to a Log Analytics workspace will go into resource specific tables, instead of the legacy AzureDiagnostics table. | `string` | `"AzureDiagnostics"` | no | -| log\_analytics\_workspace\_id | n/a | `string` | `null` | no | -| log\_enabled | Is this Diagnostic Log enabled? Defaults to true. | `string` | `true` | no | -| managedby | ManagedBy, eg ''. | `string` | `""` | no | -| name | Name (e.g. `app` or `cluster`). | `string` | `""` | no | -| peer\_virtual\_network\_gateway\_id | The ID of the peer virtual network gateway when creating a VNet-to-VNet connection | `any` | `null` | no | -| public\_ip\_allocation\_method | Defines the allocation method for this IP address. Possible values are Static or Dynamic. Defaults to Dynamic | `string` | `"Dynamic"` | no | -| public\_ip\_sku | The SKU of the Public IP. Accepted values are Basic and Standard. Defaults to Basic | `string` | `"Basic"` | no | -| repository | Terraform current module repo | `string` | `""` | no | -| resource\_group\_name | A container that holds related resources for an Azure solution | `string` | `""` | no | -| retention\_policy\_enabled | Is this Retention Policy enabled? | `bool` | `false` | no | -| sku | Configuration of the size and capacity of the virtual network gateway | `string` | `"VpnGw3"` | no | -| storage\_account\_id | The ID of the Storage Account where logs should be sent. | `string` | `null` | no | -| sts\_vpn | Set to false to prevent the module from creating any resources. | `bool` | `false` | no | -| subnet\_id | The ID of the Subnet where this Network Interface should be located in. | `string` | `""` | no | -| tags | A map of tags to add to all resources | `map(string)` | `{}` | no | -| vpn\_ad | Set to false to prevent the module from creating any resources. | `bool` | `false` | no | -| vpn\_client\_configuration | Virtual Network Gateway client configuration to accept IPSec point-to-site connections | `object({ address_space = string, vpn_client_protocols = list(string), aad_tenant = string, aad_audience = string, aad_issuer = string, vpn_auth_types = list(string) })` | `null` | no | -| vpn\_client\_configuration\_c | Virtual Network Gateway client configuration to accept IPSec point-to-site connections | `object({ address_space = string, vpn_client_protocols = list(string), certificate = string })` | `null` | no | -| vpn\_gateway\_name | The name of the Virtual Network Gateway | `string` | `""` | no | -| vpn\_gw\_generation | The Generation of the Virtual Network gateway. Possible values include Generation1, Generation2 or None | `string` | `"Generation2"` | no | -| vpn\_gw\_sku | Configuration of the size and capacity of the virtual network gateway. Valid options are Basic, VpnGw3, VpnGw2, VpnGw3, VpnGw4,VpnGw5, VpnGw3AZ, VpnGw3, VpnGw3AZ,VpnGw4AZ and VpnGw5AZ and depend on the type, vpn\_type and generation arguments | `string` | `"VpnGw3"` | no | -| vpn\_type | The routing type of the Virtual Network Gateway. Valid options are RouteBased or PolicyBased. Defaults to RouteBased | `string` | `"RouteBased"` | no | -| vpn\_with\_certificate | Set to false to prevent the module from creating any resources. | `bool` | `false` | no | +| [diagnostic\_setting\_enable](#input\_diagnostic\_setting\_enable) | n/a | `bool` | `false` | no | +| [enable](#input\_enable) | Flag to control module creation. | `bool` | `true` | no | +| [enable\_active\_active](#input\_enable\_active\_active) | If true, an active-active Virtual Network Gateway will be created. An active-active gateway requires a HighPerformance or an UltraPerformance sku. If false, an active-standby gateway will be created. Defaults to false. | `bool` | `false` | no | +| [enable\_bgp](#input\_enable\_bgp) | If true, BGP (Border Gateway Protocol) will be enabled for this Virtual Network Gateway. Defaults to false | `bool` | `false` | no | +| [environment](#input\_environment) | Environment (e.g. `prod`, `dev`, `staging`). | `string` | `""` | no | +| [eventhub\_authorization\_rule\_id](#input\_eventhub\_authorization\_rule\_id) | Specifies the ID of an Event Hub Namespace Authorization Rule used to send Diagnostics Data. | `string` | `null` | no | +| [eventhub\_name](#input\_eventhub\_name) | Specifies the name of the Event Hub where Diagnostics Data should be sent. | `string` | `null` | no | +| [express\_route\_circuit\_id](#input\_express\_route\_circuit\_id) | The ID of the Express Route Circuit when creating an ExpressRoute connection | `string` | `null` | no | +| [gateway\_connection\_protocol](#input\_gateway\_connection\_protocol) | The IKE protocol version to use. Possible values are IKEv1 and IKEv2. Defaults to IKEv2 | `string` | `"IKEv2"` | no | +| [gateway\_connection\_type](#input\_gateway\_connection\_type) | The type of connection. Valid options are IPsec (Site-to-Site), ExpressRoute (ExpressRoute), and Vnet2Vnet (VNet-to-VNet) | `string` | `"IPsec"` | no | +| [gateway\_type](#input\_gateway\_type) | The type of the Virtual Network Gateway. Valid options are Vpn or ExpressRoute | `string` | `"Vpn"` | no | +| [label\_order](#input\_label\_order) | Label order, e.g. sequence of application name and environment `name`,`environment`,'attribute' [`webserver`,`qa`,`devops`,`public`,] . | `list(any)` |
[
"name",
"environment"
]
| no | +| [local\_bgp\_settings](#input\_local\_bgp\_settings) | Local Network Gateway's BGP speaker settings | `list(object({ asn_number = number, peering_address = string, peer_weight = number }))` | `null` | no | +| [local\_networks](#input\_local\_networks) | List of local virtual network connections to connect to gateway | `list(object({ local_gw_name = string, local_gateway_address = string, local_address_space = list(string), shared_key = string }))` | `[]` | no | +| [local\_networks\_ipsec\_policy](#input\_local\_networks\_ipsec\_policy) | IPSec policy for local networks. Only a single policy can be defined for a connection. | `map(string)` | `null` | no | +| [log\_analytics\_destination\_type](#input\_log\_analytics\_destination\_type) | Possible values are AzureDiagnostics and Dedicated, default to AzureDiagnostics. When set to Dedicated, logs sent to a Log Analytics workspace will go into resource specific tables, instead of the legacy AzureDiagnostics table. | `string` | `"AzureDiagnostics"` | no | +| [log\_analytics\_workspace\_id](#input\_log\_analytics\_workspace\_id) | n/a | `string` | `null` | no | +| [log\_category](#input\_log\_category) | Categories of logs to be recorded in diagnostic setting. Acceptable values are MySqlSlowLogs , MySqlAuditLogs | `list(string)` |
[
"MySqlAuditLogs"
]
| no | +| [managedby](#input\_managedby) | ManagedBy, eg ''. | `string` | `""` | no | +| [metric\_enabled](#input\_metric\_enabled) | Whether metric diagnonsis should be enable in diagnostic settings for flexible Mysql. | `bool` | `true` | no | +| [name](#input\_name) | Name (e.g. `app` or `cluster`). | `string` | `""` | no | +| [peer\_virtual\_network\_gateway\_id](#input\_peer\_virtual\_network\_gateway\_id) | The ID of the peer virtual network gateway when creating a VNet-to-VNet connection | `string` | `null` | no | +| [public\_ip\_allocation\_method](#input\_public\_ip\_allocation\_method) | Defines the allocation method for this IP address. Possible values are Static or Dynamic. Defaults to Dynamic | `string` | `"Dynamic"` | no | +| [public\_ip\_sku](#input\_public\_ip\_sku) | The SKU of the Public IP. Accepted values are Basic and Standard. Defaults to Basic | `string` | `"Basic"` | no | +| [repository](#input\_repository) | Terraform current module repo | `string` | `""` | no | +| [resource\_group\_name](#input\_resource\_group\_name) | A container that holds related resources for an Azure solution | `string` | `""` | no | +| [sku](#input\_sku) | Configuration of the size and capacity of the virtual network gateway | `string` | `"VpnGw3"` | no | +| [storage\_account\_id](#input\_storage\_account\_id) | The ID of the Storage Account where logs should be sent. | `string` | `null` | no | +| [sts\_vpn](#input\_sts\_vpn) | Set to false to prevent the module from creating any resources. | `bool` | `false` | no | +| [subnet\_id](#input\_subnet\_id) | The ID of the Subnet where this Network Interface should be located in. | `string` | `""` | no | +| [vpn\_ad](#input\_vpn\_ad) | Set to false to prevent the module from creating any resources. | `bool` | `false` | no | +| [vpn\_client\_configuration](#input\_vpn\_client\_configuration) | Virtual Network Gateway client configuration to accept IPSec point-to-site connections | `object({ address_space = string, vpn_client_protocols = list(string), aad_tenant = string, aad_audience = string, aad_issuer = string, vpn_auth_types = list(string) })` | `null` | no | +| [vpn\_client\_configuration\_c](#input\_vpn\_client\_configuration\_c) | Virtual Network Gateway client configuration to accept IPSec point-to-site connections | `object({ address_space = string, vpn_client_protocols = list(string), certificate = string })` | `null` | no | +| [vpn\_gw\_generation](#input\_vpn\_gw\_generation) | The Generation of the Virtual Network gateway. Possible values include Generation1, Generation2 or None | `string` | `"Generation2"` | no | +| [vpn\_gw\_sku](#input\_vpn\_gw\_sku) | Configuration of the size and capacity of the virtual network gateway. Valid options are Basic, VpnGw3, VpnGw2, VpnGw3, VpnGw4,VpnGw5, VpnGw3AZ, VpnGw3, VpnGw3AZ,VpnGw4AZ and VpnGw5AZ and depend on the type, vpn\_type and generation arguments | `string` | `"VpnGw3"` | no | +| [vpn\_type](#input\_vpn\_type) | The routing type of the Virtual Network Gateway. Valid options are RouteBased or PolicyBased. Defaults to RouteBased | `string` | `"RouteBased"` | no | +| [vpn\_with\_certificate](#input\_vpn\_with\_certificate) | Set to false to prevent the module from creating any resources. | `bool` | `false` | no | ## Outputs | Name | Description | |------|-------------| -| local\_network\_gw\_connection\_id | The ID of the Virtual Network Gateway Connection. | -| local\_network\_gw\_id | The ID of the Local Network Gateway. | -| vpn\_gw\_id | The ID of the Virtual Network Gateway. | -| vpn\_gw\_id\_certificate | The ID of the Virtual Network Gateway. | +| [local\_network\_gw\_connection\_id](#output\_local\_network\_gw\_connection\_id) | The ID of the Virtual Network Gateway Connection. | +| [local\_network\_gw\_id](#output\_local\_network\_gw\_id) | The ID of the Local Network Gateway. | +| [vpn\_gw\_id](#output\_vpn\_gw\_id) | The ID of the Virtual Network Gateway. | +| [vpn\_gw\_id\_certificate](#output\_vpn\_gw\_id\_certificate) | The ID of the Virtual Network Gateway. | + +output-values: + enabled: false + from: "" +sort: + enabled: true + by: name +<<<<<<< HEAD ## Testing -In this module testing is performed with [terratest](https://github.com/gruntwork-io/terratest) and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a [GO environment](https://golang.org/doc/install) in your system. +In this module testing is performed with [terratest](https://github.com/gruntwork-io/terratest) and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a [GO environment](https://golang.org/doc/install) in your system. You need to run the following command in the testing folder: ```hcl go test -run Test +======= +settings: + anchor: true + color: true + default: true + description: false + escape: true + hide-empty: false + html: true + indent: 2 + lockfile: true + read-comments: true + required: true + sensitive: true + type: true +>>>>>>> 1dde4fa (fix: fixed pre-commits) ``` +## Content Template +Generated content can be customized further away with `content` in configuration. +If the `content` is empty the default order of sections is used. -## Feedback +<<<<<<< HEAD +## Feedback If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/terraform-azure-vpn/issues), or feel free to drop us an email at [hello@clouddrove.com](mailto:hello@clouddrove.com). +======= +Compatible formatters for customized content are `asciidoc` and `markdown`. `content` +will be ignored for other formatters. +>>>>>>> 1dde4fa (fix: fixed pre-commits) + +`content` is a Go template with following additional variables: + +- `{{ .Header }}` +- `{{ .Footer }}` +- `{{ .Inputs }}` +- `{{ .Modules }}` +- `{{ .Outputs }}` +- `{{ .Providers }}` +- `{{ .Requirements }}` +- `{{ .Resources }}` -If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/terraform-azure-vpn)! +and following functions: -## About us +- `{{ include "relative/path/to/file" }}` -At [CloudDrove][website], we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering. +These variables are the generated output of individual sections in the selected +formatter. For example `{{ .Inputs }}` is Markdown Table representation of _inputs_ +when formatter is set to `markdown table`. -

We are The Cloud Experts!

-
-

We ❤️ Open Source and you can check out our other modules to get help with your new Cloud ideas.

+Note that sections visibility (i.e. `sections.show` and `sections.hide`) takes +precedence over the `content`. + +Additionally there's also one extra special variable avaialble to the `content`: + +- `{{ .Module }}` + +As opposed to the other variables mentioned above, which are generated sections +based on a selected formatter, the `{{ .Module }}` variable is just a `struct` +representing a [Terraform module]. + +````yaml +content: |- + Any arbitrary text can be placed anywhere in the content + + {{ .Header }} + + and even in between sections + + {{ .Providers }} + + and they don't even need to be in the default order + + {{ .Outputs }} + + include any relative files + + {{ include "relative/path/to/file" }} + + {{ .Inputs }} + + # Examples + + ```hcl + {{ include "examples/foo/main.tf" }} + ``` + + ## Resources + + {{ range .Module.Resources }} + - {{ .GetMode }}.{{ .Spec }} ({{ .Position.Filename }}#{{ .Position.Line }}) + {{- end }} +```` + +## Build on top of terraform-docs + +terraform-docs primary use-case is to be utilized as a standalone binary, but +some parts of it is also available publicly and can be imported in your project +as a library. + +```go +import ( + "github.com/terraform-docs/terraform-docs/format" + "github.com/terraform-docs/terraform-docs/print" + "github.com/terraform-docs/terraform-docs/terraform" +) + +// buildTerraformDocs for module root `path` and provided content `tmpl`. +func buildTerraformDocs(path string, tmpl string) (string, error) { + config := print.DefaultConfig() + config.ModuleRoot = path // module root path (can be relative or absolute) + + module, err := terraform.LoadWithOptions(config) + if err != nil { + return "", err + } + + // Generate in Markdown Table format + formatter := format.NewMarkdownTable(config) + + if err := formatter.Generate(module); err != nil { + return "", err + } + + // // Note: if you don't intend to provide additional template for the generated + // // content, or the target format doesn't provide templating (e.g. json, yaml, + // // xml, or toml) you can use `Content()` function instead of `Render()`. + // // `Content()` returns all the sections combined with predefined order. + // return formatter.Content(), nil + + return formatter.Render(tmpl) +} +``` + +## Plugin + +Generated output can be heavily customized with [`content`], but if using that +is not enough for your use-case, you can write your own plugin. + +In order to install a plugin the following steps are needed: + +- download the plugin and place it in `~/.tfdocs.d/plugins` (or `./.tfdocs.d/plugins`) +- make sure the plugin file name is `tfdocs-format-` +- modify [`formatter`] of `.terraform-docs.yml` file to be `` + +**Important notes:** + +- if the plugin file name is different than the example above, terraform-docs won't +be able to to pick it up nor register it properly +- you can only use plugin thorough `.terraform-docs.yml` file and it cannot be used +with CLI arguments + +To create a new plugin create a new repository called `tfdocs-format-` with +following `main.go`: + +```go +package main + +import ( + _ "embed" //nolint + + "github.com/terraform-docs/terraform-docs/plugin" + "github.com/terraform-docs/terraform-docs/print" + "github.com/terraform-docs/terraform-docs/template" + "github.com/terraform-docs/terraform-docs/terraform" +) + +func main() { + plugin.Serve(&plugin.ServeOpts{ + Name: "", + Version: "0.1.0", + Printer: printerFunc, + }) +} + +//go:embed sections.tmpl +var tplCustom []byte + +// printerFunc the function being executed by the plugin client. +func printerFunc(config *print.Config, module *terraform.Module) (string, error) { + tpl := template.New(config, + &template.Item{Name: "custom", Text: string(tplCustom)}, + ) + + rendered, err := tpl.Render("custom", module) + if err != nil { + return "", err + } + + return rendered, nil +} +``` - [website]: https://clouddrove.com - [github]: https://github.com/clouddrove - [linkedin]: https://cpco.io/linkedin - [twitter]: https://twitter.com/clouddrove/ - [email]: https://clouddrove.com/contact-us.html - [terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93&q=terraform-&type=&language= +Please refer to [tfdocs-format-template] for more details. You can create a new +repository from it by clicking on `Use this template` button. + +## Documentation + +- **Users** + - Read the [User Guide] to learn how to use terraform-docs + - Read the [Formats Guide] to learn about different output formats of terraform-docs + - Refer to [Config File Reference] for all the available configuration options +- **Developers** + - Read [Contributing Guide] before submitting a pull request + +Visit [our website] for all documentation. + +## Community + +- Discuss terraform-docs on [Slack] + +## License + +MIT License - Copyright (c) 2021 The terraform-docs Authors. + +[Chocolatey]: https://www.chocolatey.org +[Config File Reference]: https://terraform-docs.io/user-guide/configuration/ +[`content`]: https://terraform-docs.io/user-guide/configuration/content/ +[Contributing Guide]: CONTRIBUTING.md +[Formats Guide]: https://terraform-docs.io/reference/terraform-docs/ +[`formatter`]: https://terraform-docs.io/user-guide/configuration/formatter/ +[here]: https://golang.org/doc/code.html#GOPATH +[Homebrew]: https://brew.sh +[install pre-commit]: https://pre-commit.com/#install +[`terraform`]: https://www.terraform.io/downloads.html +[`output`]: https://terraform-docs.io/user-guide/configuration/output/ +[releases]: https://github.com/terraform-docs/terraform-docs/releases +[Scoop]: https://scoop.sh/ +[Slack]: https://slack.terraform-docs.io/ +[terraform-docs GitHub Action]: https://github.com/terraform-docs/gh-actions +[Terraform module]: https://pkg.go.dev/github.com/terraform-docs/terraform-docs/terraform#Module +[tfdocs-format-template]: https://github.com/terraform-docs/tfdocs-format-template +[our website]: https://terraform-docs.io/ +[User Guide]: https://terraform-docs.io/user-guide/introduction/ diff --git a/README.yaml b/README.yaml index 4e9ac20..e45cb78 100644 --- a/README.yaml +++ b/README.yaml @@ -5,7 +5,7 @@ # # Name of this project -name : Terraform AZURE VPN +name: Terraform AZURE VPN # License of this project license: "APACHE" @@ -18,18 +18,36 @@ badges: - name: "Terraform" image: "https://img.shields.io/badge/Terraform-v1.1.7-green" url: "https://www.terraform.io" + - name: "tfsec" + image: "https://github.com/clouddrove/terraform-azure-vpn/actions/workflows/tfsec.yml/badge.svg" + url: "https://github.com/clouddrove/terraform-azure-vpn/actions/workflows/tfsec.yml" - name: "Licence" image: "https://img.shields.io/badge/License-APACHE-blue.svg" url: "LICENSE.md" + - name: "Changelog" + image: "https://img.shields.io/badge/Changelog-blue" + url: "CHANGELOG.md" + +# Prerequesties to display +prerequesties: + - name: Terraform + url: https://learn.hashicorp.com/terraform/getting-started/install.html + version: ">= 1.0.0" + +providers: + - name: azure + url: https://azure.microsoft.com/ + version: ">= 3.0.0" + +module_dependencies: + - name: Labels Module + url: https://github.com/clouddrove/terraform-azure-labels + description: Provides resource tagging. # description of this project description: |- Terraform module to create vpn resource on AZURE. -# extra content -include: - - "terraform.md" -# How to use this project # How to use this project usage: |- Here are some examples of how you can use this module in your inventory structure: @@ -124,6 +142,3 @@ usage: |- ] } ``` - - - diff --git a/example/point-to-site-with-ad/main.tf b/examples/complete/main.tf similarity index 68% rename from example/point-to-site-with-ad/main.tf rename to examples/complete/main.tf index e8fb5a3..0a3e903 100644 --- a/example/point-to-site-with-ad/main.tf +++ b/examples/complete/main.tf @@ -1,14 +1,14 @@ provider "azurerm" { features {} - subscription_id = "" + subscription_id = "000000-11111-1223-XXX-XXXXXXXXXXXX" } locals { - name = "app" + name = "app-vpnd" environment = "test" } -##----------------------------------------------------------------------------- +##----------------------------------------------------------------------------- ## Resource Group module call ## Resource group in which all resources will be deployed. ##----------------------------------------------------------------------------- @@ -21,9 +21,9 @@ module "resource_group" { location = "Canada Central" } -##----------------------------------------------------------------------------- +##----------------------------------------------------------------------------- ## Virtual Network module call. -## Virtual Network in which vpn subnet(Gateway Subnet) will be created. +## Virtual Network in which vpn subnet(Gateway Subnet) will be created. ##----------------------------------------------------------------------------- module "vnet" { source = "clouddrove/vnet/azure" @@ -35,13 +35,13 @@ module "vnet" { address_space = "10.0.0.0/16" } -##----------------------------------------------------------------------------- -## Subnet module call. -## Name specific subnet for vpn will be created. +##----------------------------------------------------------------------------- +## Subnet module call. +## Name specific subnet for vpn will be created. ##----------------------------------------------------------------------------- module "subnet" { source = "clouddrove/subnet/azure" - version = "1.0.2" + version = "1.2.1" name = local.name environment = local.environment resource_group_name = module.resource_group.resource_group_name @@ -49,7 +49,7 @@ module "subnet" { virtual_network_name = join("", module.vnet.vnet_name) #subnet specific_name_subnet = true - specific_subnet_names = "GatewaySubnet" + specific_subnet_names = ["GatewaySubnet"] subnet_prefixes = ["10.0.1.0/24"] # route_table enable_route_table = false @@ -62,9 +62,28 @@ module "subnet" { ] } -##----------------------------------------------------------------------------- -## VPN module call. -## Following module will deploy point to site vpn in azure infratsructure. +##----------------------------------------------------------------------------- +## Log Analytics module call. +##----------------------------------------------------------------------------- +module "log-analytics" { + source = "clouddrove/log-analytics/azure" + version = "1.1.0" + name = local.name + environment = local.environment + create_log_analytics_workspace = true + log_analytics_workspace_sku = "PerGB2018" + retention_in_days = 90 + daily_quota_gb = "-1" + internet_ingestion_enabled = true + internet_query_enabled = true + resource_group_name = module.resource_group.resource_group_name + log_analytics_workspace_location = module.resource_group.resource_group_location + log_analytics_workspace_id = module.log-analytics.workspace_id +} + +##----------------------------------------------------------------------------- +## VPN module call. +## Following module will deploy point to site vpn in azure infratsructure. ##----------------------------------------------------------------------------- module "vpn" { depends_on = [module.vnet] @@ -84,5 +103,5 @@ module "vpn" { } #### enable diagnostic setting diagnostic_setting_enable = false - log_analytics_workspace_id = "" + log_analytics_workspace_id = module.log-analytics.workspace_id } diff --git a/example/point-to-site-with-ad/output.tf b/examples/complete/output.tf similarity index 61% rename from example/point-to-site-with-ad/output.tf rename to examples/complete/output.tf index f5cb2bd..62a0881 100644 --- a/example/point-to-site-with-ad/output.tf +++ b/examples/complete/output.tf @@ -1,5 +1,4 @@ output "vpn_gw_id" { - value = join("", module.vpn.*.vpn_gw_id) + value = module.vpn.vpn_gw_id description = "The ID of the Virtual Network Gateway." } - diff --git a/examples/complete/version.tf b/examples/complete/version.tf new file mode 100644 index 0000000..bd2c2d8 --- /dev/null +++ b/examples/complete/version.tf @@ -0,0 +1,13 @@ +# Terraform version +terraform { + required_version = ">= 1.0.0" +} + +terraform { + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = ">=3.0.0" + } + } +} diff --git a/example/point-to-site-with-certificate/main.tf b/examples/point-to-site-with-certificate/main.tf similarity index 73% rename from example/point-to-site-with-certificate/main.tf rename to examples/point-to-site-with-certificate/main.tf index 1088500..78b1ebe 100644 --- a/example/point-to-site-with-certificate/main.tf +++ b/examples/point-to-site-with-certificate/main.tf @@ -1,6 +1,6 @@ provider "azurerm" { features {} - subscription_id = "" + subscription_id = "000000-11111-1223-XXX-XXXXXXXXXXXX" } locals { @@ -8,7 +8,7 @@ locals { environment = "test" } -##----------------------------------------------------------------------------- +##----------------------------------------------------------------------------- ## Resource Group module call ## Resource group in which all resources will be deployed. ##----------------------------------------------------------------------------- @@ -21,9 +21,9 @@ module "resource_group" { location = "Canada Central" } -##----------------------------------------------------------------------------- +##----------------------------------------------------------------------------- ## Virtual Network module call. -## Virtual Network in which vpn subnet(Gateway Subnet) will be created. +## Virtual Network in which vpn subnet(Gateway Subnet) will be created. ##----------------------------------------------------------------------------- module "vnet" { source = "clouddrove/vnet/azure" @@ -35,13 +35,13 @@ module "vnet" { address_space = "10.0.0.0/16" } -##----------------------------------------------------------------------------- -## Subnet module call. -## Name specific subnet for vpn will be created. +##----------------------------------------------------------------------------- +## Subnet module call. +## Name specific subnet for vpn will be created. ##----------------------------------------------------------------------------- module "subnet" { source = "clouddrove/subnet/azure" - version = "1.0.2" + version = "1.2.1" name = local.name environment = local.environment resource_group_name = module.resource_group.resource_group_name @@ -49,7 +49,7 @@ module "subnet" { virtual_network_name = join("", module.vnet.vnet_name) #subnet specific_name_subnet = true - specific_subnet_names = "GatewaySubnet" + specific_subnet_names = ["GatewaySubnet"] subnet_prefixes = ["10.0.1.0/24"] # route_table enable_route_table = false @@ -62,9 +62,28 @@ module "subnet" { ] } -##----------------------------------------------------------------------------- -## VPN module call. -## Following module will deploy point to site vpn with ssl certificate in azure infratsructure. +##----------------------------------------------------------------------------- +## Log Analytics module call. +##----------------------------------------------------------------------------- +module "log-analytics" { + source = "clouddrove/log-analytics/azure" + version = "1.1.0" + name = local.name + environment = local.environment + create_log_analytics_workspace = true + log_analytics_workspace_sku = "PerGB2018" + retention_in_days = 90 + daily_quota_gb = "-1" + internet_ingestion_enabled = true + internet_query_enabled = true + resource_group_name = module.resource_group.resource_group_name + log_analytics_workspace_location = module.resource_group.resource_group_location + log_analytics_workspace_id = module.log-analytics.workspace_id +} + +##----------------------------------------------------------------------------- +## VPN module call. +## Following module will deploy point to site vpn with ssl certificate in azure infratsructure. ##----------------------------------------------------------------------------- module "vpn" { source = "../../" @@ -76,7 +95,7 @@ module "vpn" { subnet_id = module.subnet.specific_subnet_id[0] #### enable diagnostic setting diagnostic_setting_enable = false - log_analytics_workspace_id = "" + log_analytics_workspace_id = module.log-analytics.workspace_id vpn_client_configuration_c = { address_space = "172.16.201.0/24" vpn_client_protocols = ["OpenVPN", "IkeV2"] diff --git a/example/point-to-site-with-certificate/output.tf b/examples/point-to-site-with-certificate/output.tf similarity index 56% rename from example/point-to-site-with-certificate/output.tf rename to examples/point-to-site-with-certificate/output.tf index 529228c..656b26f 100644 --- a/example/point-to-site-with-certificate/output.tf +++ b/examples/point-to-site-with-certificate/output.tf @@ -1,5 +1,4 @@ output "vpn_gw_id" { - value = join("", module.vpn.*.vpn_gw_id_certificate) + value = module.vpn.vpn_gw_id_certificate description = "The ID of the Virtual Network Gateway." } - diff --git a/examples/point-to-site-with-certificate/version.tf b/examples/point-to-site-with-certificate/version.tf new file mode 100644 index 0000000..bd2c2d8 --- /dev/null +++ b/examples/point-to-site-with-certificate/version.tf @@ -0,0 +1,13 @@ +# Terraform version +terraform { + required_version = ">= 1.0.0" +} + +terraform { + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = ">=3.0.0" + } + } +} diff --git a/example/site-to-site/main.tf b/examples/site-to-site/main.tf similarity index 53% rename from example/site-to-site/main.tf rename to examples/site-to-site/main.tf index 1e3bf5c..f528eb3 100644 --- a/example/site-to-site/main.tf +++ b/examples/site-to-site/main.tf @@ -1,6 +1,6 @@ provider "azurerm" { features {} - subscription_id = "" + subscription_id = "000000-11111-1223-XXX-XXXXXXXXXXXX" } locals { @@ -8,7 +8,7 @@ locals { environment = "test" } -##----------------------------------------------------------------------------- +##----------------------------------------------------------------------------- ## Resource Group module call ## Resource group in which all resources will be deployed. ##----------------------------------------------------------------------------- @@ -21,9 +21,9 @@ module "resource_group" { location = "Canada Central" } -##----------------------------------------------------------------------------- +##----------------------------------------------------------------------------- ## Virtual Network module call. -## Virtual Network in which vpn subnet(Gateway Subnet) will be created. +## Virtual Network in which vpn subnet(Gateway Subnet) will be created. ##----------------------------------------------------------------------------- module "vnet" { source = "clouddrove/vnet/azure" @@ -35,13 +35,13 @@ module "vnet" { address_space = "10.0.0.0/16" } -##----------------------------------------------------------------------------- -## Subnet module call. -## Name specific subnet for vpn will be created. +##----------------------------------------------------------------------------- +## Subnet module call. +## Name specific subnet for vpn will be created. ##----------------------------------------------------------------------------- module "subnet" { source = "clouddrove/subnet/azure" - version = "1.0.2" + version = "1.2.1" name = local.name environment = local.environment resource_group_name = module.resource_group.resource_group_name @@ -49,7 +49,7 @@ module "subnet" { virtual_network_name = join("", module.vnet.vnet_name) #subnet specific_name_subnet = true - specific_subnet_names = "GatewaySubnet" + specific_subnet_names = ["GatewaySubnet"] subnet_prefixes = ["10.0.1.0/24"] # route_table enable_route_table = false @@ -62,22 +62,43 @@ module "subnet" { ] } -##----------------------------------------------------------------------------- -## VPN module call. -## Following module will deploy site to site vpn with ssl certificate in azure infratsructure. +##----------------------------------------------------------------------------- +## Log Analytics module call. +##----------------------------------------------------------------------------- +module "log-analytics" { + source = "clouddrove/log-analytics/azure" + version = "1.1.0" + name = local.name + environment = local.environment + create_log_analytics_workspace = true + log_analytics_workspace_sku = "PerGB2018" + retention_in_days = 90 + daily_quota_gb = "-1" + internet_ingestion_enabled = true + internet_query_enabled = true + resource_group_name = module.resource_group.resource_group_name + log_analytics_workspace_location = module.resource_group.resource_group_location + log_analytics_workspace_id = module.log-analytics.workspace_id +} + +##----------------------------------------------------------------------------- +## VPN module call. +## Following module will deploy site to site vpn with ssl certificate in azure infratsructure. ##----------------------------------------------------------------------------- module "vpn" { - depends_on = [module.vnet] - source = "../../" - name = "site-to-site" - environment = local.environment - sts_vpn = true - resource_group_name = module.resource_group.resource_group_name - subnet_id = module.subnet.specific_subnet_id[0] - gateway_type = "Vpn" + depends_on = [module.vnet] + source = "../../" + name = "site-to-site" + environment = local.environment + sts_vpn = true + resource_group_name = module.resource_group.resource_group_name + subnet_id = module.subnet.specific_subnet_id[0] + gateway_type = "Vpn" + public_ip_sku = "Standard" + public_ip_allocation_method = "Static" #### enable diagnostic setting - diagnostic_setting_enable = false - log_analytics_workspace_id = "" + diagnostic_setting_enable = true + log_analytics_workspace_id = module.log-analytics.workspace_id local_networks = [ { local_gw_name = "app-test-onpremise" @@ -86,4 +107,14 @@ module "vpn" { shared_key = "xpCGkHTBQmDvZK9HnLr7DAvH" }, ] + local_networks_ipsec_policy = { + dh_group = "ECP384" + ike_encryption = "AES256" + ike_integrity = "SHA256" + ipsec_encryption = "AES256" + ipsec_integrity = "SHA256" + pfs_group = "ECP384" + sa_datasize = null + sa_lifetime = 3600 + } } diff --git a/example/site-to-site/output.tf b/examples/site-to-site/output.tf similarity index 61% rename from example/site-to-site/output.tf rename to examples/site-to-site/output.tf index 9096924..b0c07b1 100644 --- a/example/site-to-site/output.tf +++ b/examples/site-to-site/output.tf @@ -1,13 +1,13 @@ output "vpn_gw_id" { - value = join("", module.vpn.*.vpn_gw_id) + value = module.vpn.vpn_gw_id description = "The ID of the Virtual Network Gateway." } output "local_network_gw_id" { - value = join("", module.vpn.*.local_network_gw_id) + value = module.vpn.local_network_gw_id description = "The ID of the Local Network Gateway." } output "local_network_gw_connection_id" { - value = join("", module.vpn.*.local_network_gw_connection_id) + value = module.vpn.local_network_gw_connection_id description = "The ID of the Virtual Network Gateway Connection." } diff --git a/examples/site-to-site/version.tf b/examples/site-to-site/version.tf new file mode 100644 index 0000000..bd2c2d8 --- /dev/null +++ b/examples/site-to-site/version.tf @@ -0,0 +1,13 @@ +# Terraform version +terraform { + required_version = ">= 1.0.0" +} + +terraform { + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = ">=3.0.0" + } + } +} diff --git a/main.tf b/main.tf index 1bd13fb..4badc4e 100644 --- a/main.tf +++ b/main.tf @@ -12,7 +12,7 @@ module "labels" { } ##----------------------------------------------------------------------------- -## data block called for resource group. +## data block called for resource group. ##----------------------------------------------------------------------------- data "azurerm_resource_group" "rg" { name = var.resource_group_name @@ -20,7 +20,7 @@ data "azurerm_resource_group" "rg" { ##----------------------------------------------------------------------------- ## Random string called -## Will be used further in public ip resource in domain name label. +## Will be used further in public ip resource in domain name label. ##----------------------------------------------------------------------------- resource "random_string" "str" { count = var.enable ? 1 : 0 @@ -100,7 +100,7 @@ resource "azurerm_virtual_network_gateway" "vpngw" { ##----------------------------------------------------------------------------- ## Virtual Network Gateway -## Following resource will deploy virtual network gateway with certificate. +## Following resource will deploy virtual network gateway with certificate. ##----------------------------------------------------------------------------- resource "azurerm_virtual_network_gateway" "vpngw2" { count = var.enable && var.vpn_with_certificate ? 1 : 0 @@ -178,7 +178,7 @@ resource "azurerm_virtual_network_gateway_connection" "az-hub-onprem" { resource_group_name = data.azurerm_resource_group.rg.name location = data.azurerm_resource_group.rg.location type = var.gateway_connection_type - virtual_network_gateway_id = var.sts_vpn == true ? join("", azurerm_virtual_network_gateway.vpngw.*.id) : join("", azurerm_virtual_network_gateway.vpngw2.*.id) + virtual_network_gateway_id = var.sts_vpn == true ? azurerm_virtual_network_gateway.vpngw[0].id : azurerm_virtual_network_gateway.vpngw2[0].id local_network_gateway_id = var.gateway_connection_type != "ExpressRoute" ? azurerm_local_network_gateway.localgw[count.index].id : null express_route_circuit_id = var.gateway_connection_type == "ExpressRoute" ? var.express_route_circuit_id : null peer_virtual_network_gateway_id = var.gateway_connection_type == "Vnet2Vnet" ? var.peer_virtual_network_gateway_id : null @@ -202,43 +202,30 @@ resource "azurerm_virtual_network_gateway_connection" "az-hub-onprem" { } ##----------------------------------------------------------------------------- -## Following resource will deploy diagnostic setting for virtual network gateway. +## Following resource will deploy diagnostic setting for virtual network gateway. ##----------------------------------------------------------------------------- resource "azurerm_monitor_diagnostic_setting" "main" { count = var.enable && var.diagnostic_setting_enable ? 1 : 0 name = format("%s-vpn-gateway-diagnostic-log", module.labels.id) - target_resource_id = var.vpn_ad || var.sts_vpn ? join("", azurerm_virtual_network_gateway.vpngw.*.id) : join("", azurerm_virtual_network_gateway.vpngw2.*.id) + target_resource_id = var.vpn_ad || var.sts_vpn ? azurerm_virtual_network_gateway.vpngw[0].id : azurerm_virtual_network_gateway.vpngw2[0].id storage_account_id = var.storage_account_id eventhub_name = var.eventhub_name eventhub_authorization_rule_id = var.eventhub_authorization_rule_id log_analytics_workspace_id = var.log_analytics_workspace_id log_analytics_destination_type = var.log_analytics_destination_type - metric { - category = "AllMetrics" - enabled = var.Metric_enable - retention_policy { - enabled = var.retention_policy_enabled - days = var.days - } - } - log { - category = var.category - category_group = "AllLogs" - retention_policy { - enabled = var.retention_policy_enabled - days = var.days + dynamic "enabled_log" { + for_each = var.log_category + content { + category = enabled_log.value } - enabled = var.log_enabled } - log { - category = var.category - category_group = "Audit" - retention_policy { - enabled = var.retention_policy_enabled - days = var.days + dynamic "metric" { + for_each = var.metric_enabled ? ["AllMetrics"] : [] + content { + category = metric.value + enabled = true } - enabled = var.log_enabled } lifecycle { ignore_changes = [log_analytics_destination_type] @@ -246,43 +233,30 @@ resource "azurerm_monitor_diagnostic_setting" "main" { } ##----------------------------------------------------------------------------- -## Following resource will deploy diagnostic setting for public ip. +## Following resource will deploy diagnostic setting for public ip. ##----------------------------------------------------------------------------- resource "azurerm_monitor_diagnostic_setting" "pip_gw" { count = var.enable && var.diagnostic_setting_enable ? 1 : 0 name = format("%s-gw-pip-diagnostic-log", module.labels.id) - target_resource_id = join("", azurerm_public_ip.pip_gw.*.id) + target_resource_id = azurerm_public_ip.pip_gw[0].id storage_account_id = var.storage_account_id eventhub_name = var.eventhub_name eventhub_authorization_rule_id = var.eventhub_authorization_rule_id log_analytics_workspace_id = var.log_analytics_workspace_id log_analytics_destination_type = var.log_analytics_destination_type - metric { - category = "AllMetrics" - enabled = var.Metric_enable - retention_policy { - enabled = var.retention_policy_enabled - days = var.days - } - } - log { - category = var.category - category_group = "AllLogs" - retention_policy { - enabled = var.retention_policy_enabled - days = var.days + dynamic "enabled_log" { + for_each = var.log_category + content { + category = enabled_log.value } - enabled = var.log_enabled } - log { - category = var.category - category_group = "Audit" - retention_policy { - enabled = var.retention_policy_enabled - days = var.days + dynamic "metric" { + for_each = var.metric_enabled ? ["AllMetrics"] : [] + content { + category = metric.value + enabled = true } - enabled = var.log_enabled } lifecycle { ignore_changes = [log_analytics_destination_type] diff --git a/output.tf b/output.tf index da7c030..d1d6593 100644 --- a/output.tf +++ b/output.tf @@ -1,18 +1,19 @@ output "vpn_gw_id" { - value = join("", azurerm_virtual_network_gateway.vpngw.*.id) + value = try(azurerm_virtual_network_gateway.vpngw[0].id, null) description = "The ID of the Virtual Network Gateway." } output "vpn_gw_id_certificate" { - value = join("", azurerm_virtual_network_gateway.vpngw2.*.id) + value = try(azurerm_virtual_network_gateway.vpngw2[0].id, null) description = "The ID of the Virtual Network Gateway." } output "local_network_gw_id" { - value = join("", azurerm_local_network_gateway.localgw.*.id) + value = try(azurerm_local_network_gateway.localgw[0].id, null) description = "The ID of the Local Network Gateway." } + output "local_network_gw_connection_id" { - value = join("", azurerm_virtual_network_gateway_connection.az-hub-onprem.*.id) + value = try(azurerm_virtual_network_gateway_connection.az-hub-onprem[0].id, null) description = "The ID of the Virtual Network Gateway Connection." } diff --git a/variables.tf b/variables.tf index 6404e27..2bc8aa8 100644 --- a/variables.tf +++ b/variables.tf @@ -4,13 +4,6 @@ variable "resource_group_name" { description = "A container that holds related resources for an Azure solution" } -variable "location" { - type = string - default = "" - description = "The location/region to keep all your network resources. To get the list of all locations with table format from azure cli, run 'az account list-locations -o table'" - -} - variable "subnet_id" { type = string default = "" @@ -23,30 +16,22 @@ variable "name" { description = "Name (e.g. `app` or `cluster`)." } -variable "vpn_gateway_name" { - type = string - default = "" - description = "The name of the Virtual Network Gateway" - -} - variable "public_ip_allocation_method" { type = string - default = "Dynamic" + default = "Static" description = "Defines the allocation method for this IP address. Possible values are Static or Dynamic. Defaults to Dynamic" - } variable "public_ip_sku" { + type = string + default = "Standard" description = "The SKU of the Public IP. Accepted values are Basic and Standard. Defaults to Basic" - default = "Basic" } variable "gateway_type" { type = string default = "Vpn" description = "The type of the Virtual Network Gateway. Valid options are Vpn or ExpressRoute" - } variable "vpn_type" { @@ -58,29 +43,20 @@ variable "vpn_type" { variable "vpn_gw_sku" { type = string - default = "VpnGw3" + default = "VpnGw1" description = "Configuration of the size and capacity of the virtual network gateway. Valid options are Basic, VpnGw3, VpnGw2, VpnGw3, VpnGw4,VpnGw5, VpnGw3AZ, VpnGw3, VpnGw3AZ,VpnGw4AZ and VpnGw5AZ and depend on the type, vpn_type and generation arguments" } -variable "expressroute_sku" { - type = string - default = "Standard" - description = "Configuration of the size and capacity of the virtual network gateway for ExpressRoute type. Valid options are Standard, HighPerformance, UltraPerformance, ErGw1AZ, ErGw2AZ, ErGw3AZ and depend on the type, vpn_type and generation arguments" - -} - variable "vpn_gw_generation" { type = string - default = "Generation2" + default = "Generation1" description = "The Generation of the Virtual Network gateway. Possible values include Generation1, Generation2 or None" - } variable "enable_active_active" { type = bool default = false description = "If true, an active-active Virtual Network Gateway will be created. An active-active gateway requires a HighPerformance or an UltraPerformance sku. If false, an active-standby gateway will be created. Defaults to false." - } variable "enable_bgp" { @@ -89,32 +65,18 @@ variable "enable_bgp" { description = "If true, BGP (Border Gateway Protocol) will be enabled for this Virtual Network Gateway. Defaults to false" } -variable "bgp_asn_number" { - type = string - default = "65515" - description = "The Autonomous System Number (ASN) to use as part of the BGP" - -} - -variable "bgp_peering_address" { - type = string - default = "" - description = "The BGP peer IP address of the virtual network gateway. This address is needed to configure the created gateway as a BGP Peer on the on-premises VPN devices. The IP address must be part of the subnet of the Virtual Network Gateway." - -} - -variable "bgp_peer_weight" { - type = string - default = "" - description = "The weight added to routes which have been learned through BGP peering. Valid values can be between 0 and 100" -} - variable "vpn_client_configuration" { type = object({ address_space = string, vpn_client_protocols = list(string), aad_tenant = string, aad_audience = string, aad_issuer = string, vpn_auth_types = list(string) }) default = null description = "Virtual Network Gateway client configuration to accept IPSec point-to-site connections" } +variable "local_networks_ipsec_policy" { + type = map(string) + default = null + description = "IPSec policy for local networks. Only a single policy can be defined for a connection." +} + variable "vpn_client_configuration_c" { type = object({ address_space = string, vpn_client_protocols = list(string), certificate = string }) default = null @@ -134,18 +96,21 @@ variable "local_bgp_settings" { } variable "gateway_connection_type" { - description = "The type of connection. Valid options are IPsec (Site-to-Site), ExpressRoute (ExpressRoute), and Vnet2Vnet (VNet-to-VNet)" + type = string default = "IPsec" + description = "The type of connection. Valid options are IPsec (Site-to-Site), ExpressRoute (ExpressRoute), and Vnet2Vnet (VNet-to-VNet)" } variable "express_route_circuit_id" { - description = "The ID of the Express Route Circuit when creating an ExpressRoute connection" + type = string default = null + description = "The ID of the Express Route Circuit when creating an ExpressRoute connection" } variable "peer_virtual_network_gateway_id" { - description = "The ID of the peer virtual network gateway when creating a VNet-to-VNet connection" + type = string default = null + description = "The ID of the peer virtual network gateway when creating a VNet-to-VNet connection" } variable "gateway_connection_protocol" { @@ -154,31 +119,12 @@ variable "gateway_connection_protocol" { type = string } -variable "local_networks_ipsec_policy" { - description = "IPSec policy for local networks. Only a single policy can be defined for a connection." - default = null -} - -variable "tags" { - description = "A map of tags to add to all resources" - type = map(string) - default = {} -} - variable "sku" { type = string - default = "VpnGw3" + default = "VpnGw1" description = "Configuration of the size and capacity of the virtual network gateway" } -#Module : LABEL -#Description : Terraform label module variables. -variable "app_name" { - type = string - default = "" - description = "Name (e.g. `app` or `cluster`)." -} - variable "environment" { type = string default = "" @@ -226,21 +172,6 @@ variable "log_analytics_destination_type" { default = "AzureDiagnostics" description = "Possible values are AzureDiagnostics and Dedicated, default to AzureDiagnostics. When set to Dedicated, logs sent to a Log Analytics workspace will go into resource specific tables, instead of the legacy AzureDiagnostics table." } -variable "retention_policy_enabled" { - type = bool - default = false - description = "Is this Retention Policy enabled?" -} -variable "days" { - type = number - default = "90" - description = " The number of days for which this Retention Policy should apply." -} -variable "Metric_enable" { - type = bool - default = true - description = "Is this Diagnostic Metric enabled? Defaults to true." -} variable "diagnostic_setting_enable" { type = bool default = false @@ -249,17 +180,6 @@ variable "log_analytics_workspace_id" { type = string default = null } - -variable "category" { - type = string - default = null - description = " The name of a Diagnostic Log Category Group for this Resource." -} -variable "log_enabled" { - type = string - default = true - description = " Is this Diagnostic Log enabled? Defaults to true." -} variable "storage_account_id" { type = string default = null @@ -281,3 +201,15 @@ variable "enable" { default = true description = "Flag to control module creation." } + +variable "metric_enabled" { + type = bool + default = true + description = "Whether metric diagnonsis should be enable in diagnostic settings for flexible Mysql." +} + +variable "log_category" { + type = list(string) + default = ["MySqlAuditLogs"] + description = "Categories of logs to be recorded in diagnostic setting. Acceptable values are MySqlSlowLogs , MySqlAuditLogs " +} diff --git a/versions.tf b/versions.tf index bd2c2d8..0158db9 100644 --- a/versions.tf +++ b/versions.tf @@ -9,5 +9,9 @@ terraform { source = "hashicorp/azurerm" version = ">=3.0.0" } + random = { + source = "hashicorp/random" + version = ">= 3.1" + } } }