From 44ae29cff5357bc1edf5b8dfca22e1697766fa18 Mon Sep 17 00:00:00 2001 From: Matt White <16320656+matt-FFFFFF@users.noreply.github.com> Date: Tue, 29 Aug 2023 16:25:09 +0100 Subject: [PATCH 1/3] feat: structure --- .github/dependabot.yml | 12 ++++ .github/policies/avmrequiredfiles.yml | 4 +- .github/workflows/docs-check.yml | 47 ++++++++++++++ .github/workflows/version-check.yml | 1 + .terraform-docs.yml | 67 ++++++++++++++++++++ Makefile | 17 +++++ README.md | 81 +++++++++++++++++------- .github/workflows/.gitkeep => _footer.md | 0 _header.md | 5 ++ examples/README.md | 6 ++ locals.tf | 1 + main.tf | 1 + modules/README.md | 4 ++ outputs.tf | 1 + terraform.tf | 10 +++ 15 files changed, 232 insertions(+), 25 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/docs-check.yml create mode 100644 .terraform-docs.yml create mode 100644 Makefile rename .github/workflows/.gitkeep => _footer.md (100%) create mode 100644 _header.md create mode 100644 examples/README.md create mode 100644 locals.tf create mode 100644 main.tf create mode 100644 modules/README.md create mode 100644 outputs.tf create mode 100644 terraform.tf diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d5037e3 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +--- +version: 2 + +updates: + - package-ecosystem: gomod + directory: /tests + schedule: + interval: daily + - package-ecosystem: "github-actions" + directory: "/.github/workflows" + schedule: + interval: daily diff --git a/.github/policies/avmrequiredfiles.yml b/.github/policies/avmrequiredfiles.yml index b51b168..41647d9 100644 --- a/.github/policies/avmrequiredfiles.yml +++ b/.github/policies/avmrequiredfiles.yml @@ -12,12 +12,14 @@ configuration: repository. A pull request has been opened to add the missing files. When the pr is merged this issue will be closed automatically. - prTitle: 'feat: add AVM mandatory file(s) to this repo' + prTitle: "feat: add AVM mandatory file(s) to this repo" prBody: | This repository needs the standard workflow and policy files to ensure compliance. file: - path: .github/workflows/version-check.yml prContentLink: https://raw.githubusercontent.com/Azure/terraform-azurerm-avm-template/main/.github/workflows/version-check.yml + - path: .github/workflows/docs-check.yml + prContentLink: https://raw.githubusercontent.com/Azure/terraform-azurerm-avm-template/main/.github/workflows/docs-check.yml - path: .github/policies/avmrequiredfiles.yml prContentLink: https://raw.githubusercontent.com/Azure/terraform-azurerm-avm-template/main/.github/policies/avmrequiredfiles.yml - path: .github/policies/branchprotection.yml diff --git a/.github/workflows/docs-check.yml b/.github/workflows/docs-check.yml new file mode 100644 index 0000000..1e029d2 --- /dev/null +++ b/.github/workflows/docs-check.yml @@ -0,0 +1,47 @@ +--- + name: docs-check + + on: + pull_request: + types: ['opened', 'reopened', 'synchronize'] + merge_group: + workflow_dispatch: + + concurrency: + group: docsfmttest-${{ github.event.pull_request.head.repo.full_name }}/${{ github.head_ref || github.run_id }} + cancel-in-progress: true + + jobs: + docsfmttest: + name: docs-check + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup go + uses: actions/setup-go@v4 + with: + go-version: '1.20.x' + # cache-dependency-path: tests/go.sum + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v2 + with: + terraform_wrapper: false + + - name: Install tools + run: make tools + + - name: Check fmt and docs + run: | + echo "==> Running make fmt & make docs" + make fmt + make docs + echo "==> Testing for changes to tracked files" + CHANGES=$(git status -suno) + if [ "$CHANGES" ]; then + echo "Repository formatting or documentation is not correct." + echo "Run 'make fmt && make docs' locally and commit the changes to fix." + exit 1 + fi diff --git a/.github/workflows/version-check.yml b/.github/workflows/version-check.yml index 1bb3f6c..fe5d2cc 100644 --- a/.github/workflows/version-check.yml +++ b/.github/workflows/version-check.yml @@ -3,6 +3,7 @@ name: version-check on: workflow_dispatch: + merge_group: pull_request: branches: - main diff --git a/.terraform-docs.yml b/.terraform-docs.yml new file mode 100644 index 0000000..1820ab0 --- /dev/null +++ b/.terraform-docs.yml @@ -0,0 +1,67 @@ +### To generate the output file to partially incorporate in the README.md, +### Execute this command in the Terraform module's code folder: +# terraform-docs -c .terraform-docs.yml . + +formatter: "markdown document" # this is required + +version: "0.16.0" + +header-from: "_header.md" +footer-from: "_footer.md" + +recursive: + enabled: false + path: modules + +sections: + hide: [] + show: [] + +content: |- + {{ .Header }} + + + {{ .Requirements }} + + {{ .Providers }} + + {{ .Resources }} + + + {{ .Inputs }} + + {{ .Outputs }} + + {{ .Modules }} + + {{ .Footer }} + +output: + file: README.md + mode: replace + template: |- + + {{ .Content }} + +output-values: + enabled: false + from: "" + +sort: + enabled: true + by: required + +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 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..450066a --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +.PHONY: docs +docs: + terraform-docs -c .terraform-docs.yml . + +.PHONY: fmt +fmt: + @echo "==> Fixing source code with gofmt..." + find ./tests -name '*.go' | grep -v vendor | xargs gofmt -s -w + @echo "==> Fixing Terraform code with terraform fmt..." + terraform fmt -recursive + @echo "==> Fixing embedded Terraform with terrafmt..." + find . | egrep ".md|.tf" | grep -v README.md | sort | while read f; do terrafmt fmt $$f; done + +.PHONY: tools +tools: + go install github.com/katbyte/terrafmt@latest + go install github.com/terraform-docs/terraform-docs@latest diff --git a/README.md b/README.md index 5cd7cec..24f633a 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,66 @@ -# Project + +# terraform-azurerm-avm-template -> This repo has been populated by an initial template to help get you started. Please -> make sure to update the content to build a great experience for community-building. +This is a template repo for Terraform Azure Verified Modules. -As the maintainer of this project, please make a few updates: +TODO: Provide instructions or links to spec to explain how to use this template. -- Improving this README.MD file to provide a great experience -- Updating SUPPORT.MD with content about this project's support experience -- Understanding the security reporting process in SECURITY.MD -- Remove this section from the README + +## Requirements -## Contributing +The following requirements are needed by this module: -This project welcomes contributions and suggestions. Most contributions require you to agree to a -Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us -the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. +- [terraform](#requirement\_terraform) (>= 1.0.0) -When you submit a pull request, a CLA bot will automatically determine whether you need to provide -a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions -provided by the bot. You will only need to do this once across all repos using our CLA. +- [azurerm](#requirement\_azurerm) (>= 3.71.0) -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or -contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. +## Providers -## Trademarks +The following providers are used by this module: -This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft -trademarks or logos is subject to and must follow -[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). -Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. -Any use of third-party trademarks or logos are subject to those third-party's policies. +- [azurerm](#provider\_azurerm) (>= 3.71.0) + +- [random](#provider\_random) + +## Resources + +The following resources are used by this module: + +- [azurerm_resource_group_template_deployment.telemetry](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group_template_deployment) (resource) +- [random_id.telemetry](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) (resource) + + +## Required Inputs + +The following input variables are required: + +### [resource\_group\_name](#input\_resource\_group\_name) + +Description: The resource group where the resources will be deployed. + +Type: `string` + +## Optional Inputs + +The following input variables are optional (have default values): + +### [enable\_telemetry](#input\_enable\_telemetry) + +Description: This variable controls whether or not telemetry is enabled for the module. +For more information see https://aka.ms/avm/telemetry. +If it is set to false, then no telemetry will be collected. + +Type: `bool` + +Default: `true` + +## Outputs + +No outputs. + +## Modules + +No modules. + + + \ No newline at end of file diff --git a/.github/workflows/.gitkeep b/_footer.md similarity index 100% rename from .github/workflows/.gitkeep rename to _footer.md diff --git a/_header.md b/_header.md new file mode 100644 index 0000000..5e7d189 --- /dev/null +++ b/_header.md @@ -0,0 +1,5 @@ +# terraform-azurerm-avm-template + +This is a template repo for Terraform Azure Verified Modules. + +TODO: Provide instructions or links to spec to explain how to use this template. diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..288493b --- /dev/null +++ b/examples/README.md @@ -0,0 +1,6 @@ +# Examples + +Create a directory for each example. +Create a README.md file in each directory to help consumers understand the example. + +> **Note:** Examples must be deployable and idempotent. Ensure that no input variables are requried to run the example and that random values are used to ensure unique resource names. E.g. use `random_pet` to generate a unique name for a resource. diff --git a/locals.tf b/locals.tf new file mode 100644 index 0000000..a323ca4 --- /dev/null +++ b/locals.tf @@ -0,0 +1 @@ +# TODO: insert locals here. diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..840498f --- /dev/null +++ b/main.tf @@ -0,0 +1 @@ +# TODO: insert resources here. diff --git a/modules/README.md b/modules/README.md new file mode 100644 index 0000000..0cfb517 --- /dev/null +++ b/modules/README.md @@ -0,0 +1,4 @@ +# Sub-modules + +Create directories for each sub-module if required. +README.md files will be automatically generated for each sub-module using `terraform-docs`. diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..9557116 --- /dev/null +++ b/outputs.tf @@ -0,0 +1 @@ +# TODO: insert outputs here. diff --git a/terraform.tf b/terraform.tf new file mode 100644 index 0000000..d12ba19 --- /dev/null +++ b/terraform.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0.0" + required_providers { + # TODO: Ensure all required providers are listed here. + azurerm = { + source = "hashicorp/azurerm" + version = ">= 3.71.0" + } + } +} From 20bb1b39231727801a0856cdba8391db7aa8ee40 Mon Sep 17 00:00:00 2001 From: Matt White <16320656+matt-FFFFFF@users.noreply.github.com> Date: Tue, 29 Aug 2023 16:33:12 +0100 Subject: [PATCH 2/3] add tests dir --- tests/README.md | 3 +++ tests/e2e/.gitkeep | 0 tests/unit/.gitkeep | 0 tests/upgrade/.gitkeep | 0 4 files changed, 3 insertions(+) create mode 100644 tests/README.md create mode 100644 tests/e2e/.gitkeep create mode 100644 tests/unit/.gitkeep create mode 100644 tests/upgrade/.gitkeep diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..b226699 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,3 @@ +# Tests + +Create tests in the provided subdirectories. diff --git a/tests/e2e/.gitkeep b/tests/e2e/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/.gitkeep b/tests/unit/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/upgrade/.gitkeep b/tests/upgrade/.gitkeep new file mode 100644 index 0000000..e69de29 From 42533a15470898aa71792668ba2a0d84567c74de Mon Sep 17 00:00:00 2001 From: Matt White <16320656+matt-FFFFFF@users.noreply.github.com> Date: Tue, 29 Aug 2023 16:40:35 +0100 Subject: [PATCH 3/3] test add .go file --- SUPPORT.md | 50 +++++++++++++++++++++--------------------- tests/e2e/.gitkeep | 0 tests/unit/.gitkeep | 0 tests/unit/unit.go | 1 + tests/upgrade/.gitkeep | 0 5 files changed, 26 insertions(+), 25 deletions(-) delete mode 100644 tests/e2e/.gitkeep delete mode 100644 tests/unit/.gitkeep create mode 100644 tests/unit/unit.go delete mode 100644 tests/upgrade/.gitkeep diff --git a/SUPPORT.md b/SUPPORT.md index 291d4d4..eaf439a 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -1,25 +1,25 @@ -# TODO: The maintainer of this repo has not yet edited this file - -**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project? - -- **No CSS support:** Fill out this template with information about how to file issues and get help. -- **Yes CSS support:** Fill out an intake form at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work with/help you to determine next steps. -- **Not sure?** Fill out an intake as though the answer were "Yes". CSS will help you decide. - -*Then remove this first heading from this SUPPORT.MD file before publishing your repo.* - -# Support - -## How to file issues and get help - -This project uses GitHub Issues to track bugs and feature requests. Please search the existing -issues before filing new issues to avoid duplicates. For new issues, file your bug or -feature request as a new Issue. - -For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE -FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER -CHANNEL. WHERE WILL YOU HELP PEOPLE?**. - -## Microsoft Support Policy - -Support for this **PROJECT or PRODUCT** is limited to the resources listed above. +# TODO: The maintainer of this repo has not yet edited this file + +**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project? + +- **No CSS support:** Fill out this template with information about how to file issues and get help. +- **Yes CSS support:** Fill out an intake form at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work with/help you to determine next steps. +- **Not sure?** Fill out an intake as though the answer were "Yes". CSS will help you decide. + +*Then remove this first heading from this SUPPORT.MD file before publishing your repo.* + +# Support + +## How to file issues and get help + +This project uses GitHub Issues to track bugs and feature requests. Please search the existing +issues before filing new issues to avoid duplicates. For new issues, file your bug or +feature request as a new Issue. + +For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE +FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER +CHANNEL. WHERE WILL YOU HELP PEOPLE?**. + +## Microsoft Support Policy + +Support for this **PROJECT or PRODUCT** is limited to the resources listed above. diff --git a/tests/e2e/.gitkeep b/tests/e2e/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/unit/.gitkeep b/tests/unit/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/unit/unit.go b/tests/unit/unit.go new file mode 100644 index 0000000..67177cf --- /dev/null +++ b/tests/unit/unit.go @@ -0,0 +1 @@ +package unit diff --git a/tests/upgrade/.gitkeep b/tests/upgrade/.gitkeep deleted file mode 100644 index e69de29..0000000