Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate Examples Terraform Configurations via CI Testing #12861

Closed
bflad opened this issue Apr 16, 2020 · 2 comments · Fixed by #13196
Closed

Validate Examples Terraform Configurations via CI Testing #12861

bflad opened this issue Apr 16, 2020 · 2 comments · Fixed by #13196
Labels
enhancement Requests to existing resources that expand the functionality or scope. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Milestone

Comments

@bflad
Copy link
Contributor

bflad commented Apr 16, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

The Terraform AWS Provider codebase contains full Terraform configurations in the examples directory. Each of these directories should at a minimum have terraform fmt and terraform validate ran during pull requests for testing.

As a potential implementation, there are officially supported Terraform GitHub Actions available: https://github.com/hashicorp/terraform-github-actions/

For example (needs to be updated to handle per-directory checks):

name: Examples Checks
on:
  pull_request:
    paths:
      - examples/**

env:
  tf_version: 'latest'
  tf_working_dir: '.'
jobs:
  terraform:
    runs-on: ubuntu-latest
    steps:
      - name: 'Checkout'
        uses: actions/checkout@master
      - name: 'terraform fmt'
        uses: hashicorp/terraform-github-actions@v0.8.0
        with:
          tf_actions_version: ${{ env.tf_version }}
          tf_actions_subcommand: 'fmt'
          tf_actions_working_dir: ${{ env.tf_working_dir }}
          tf_actions_comment: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: 'terraform init'
        uses: hashicorp/terraform-github-actions@v0.8.0
        with:
          tf_actions_version: ${{ env.tf_version }}
          tf_actions_subcommand: 'init'
          tf_actions_working_dir: ${{ env.tf_working_dir }}
          tf_actions_comment: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: 'terraform validate'
        uses: hashicorp/terraform-github-actions@v0.8.0
        with:
          tf_actions_version: ${{ env.tf_version }}
          tf_actions_subcommand: 'validate'
          tf_actions_working_dir: ${{ env.tf_working_dir }}
          tf_actions_comment: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

References

@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Apr 16, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Apr 16, 2020
@bflad bflad removed the needs-triage Waiting for first response or review from a maintainer. label Apr 16, 2020
bflad added a commit that referenced this issue May 7, 2020
…nd 0.12.24

Reference: #12861

GitHub Action that verifies the examples against the latest provider supported Terraform versions (0.11.14 and 0.12.24 currently) with the following commands:

- `terraform init`
- `terraform fmt -check`
- `terraform validate`

Most of the complexity in this workflow is supporting the `go build` of the provider that substitutes as the latest version available in releases/registry (determined via Git release tags). This allows unreleased functionality to be tested. We cannot use `-plugin-dir` since would prevent other providers in use by some of the examples (e.g. random) from downloading.

This changeset also standardizes around using `terraform.template.tfvars` for declaring required variables and already in use by a few of the existing examples directories. This is especially required in Terraform 0.11 for `terraform validate`. Other changes here are bare minimum fixes to get everything passing in both Terraform versions. Later design proposals should guide any major refactorings of the examples.
@bflad bflad added this to the v2.61.0 milestone May 7, 2020
bflad added a commit that referenced this issue May 7, 2020
…nd 0.12.24 (#13196)

* fixed issue #9612

* fixed issue #9612

* fixed cidrsubnet implementation is off by 1 in the networking example.

* tests/provider: Initial examples checking against Terraform 0.11.14 and 0.12.24

Reference: #12861

GitHub Action that verifies the examples against the latest provider supported Terraform versions (0.11.14 and 0.12.24 currently) with the following commands:

- `terraform init`
- `terraform fmt -check`
- `terraform validate`

Most of the complexity in this workflow is supporting the `go build` of the provider that substitutes as the latest version available in releases/registry (determined via Git release tags). This allows unreleased functionality to be tested. We cannot use `-plugin-dir` since would prevent other providers in use by some of the examples (e.g. random) from downloading.

This changeset also standardizes around using `terraform.template.tfvars` for declaring required variables and already in use by a few of the existing examples directories. This is especially required in Terraform 0.11 for `terraform validate`. Other changes here are bare minimum fixes to get everything passing in both Terraform versions. Later design proposals should guide any major refactorings of the examples.

Co-authored-by: Aidan Melen <amelen@exactsciences.com>
@ghost
Copy link

ghost commented May 8, 2020

This has been released in version 2.61.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Jun 6, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Jun 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
1 participant