-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from clouddrove/cd-307
use terraform letast version
- Loading branch information
Showing
8 changed files
with
108 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,83 @@ | ||
name: 'Terraform GitHub Actions' | ||
name: static-checks | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
fmt: | ||
name: 'terraform fmt' | ||
versionExtract: | ||
name: Get min/max versions | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 'Checkout' | ||
uses: actions/checkout@v2.3.4 | ||
|
||
- name: 'Terraform Format' | ||
uses: 'clouddrove/github-actions@v7.0' | ||
with: | ||
actions_subcommand: 'fmt' | ||
|
||
validate: | ||
name: 'terraform validate' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 'Checkout' | ||
uses: actions/checkout@v2.3.4 | ||
|
||
- name: 'Configure AWS Credentials' | ||
uses: clouddrove/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }} | ||
aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }} | ||
aws-region: us-east-2 | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: 'Terraform init' | ||
uses: 'clouddrove/github-actions@v7.0' | ||
with: | ||
actions_subcommand: 'init' | ||
tf_actions_working_dir: ./_example | ||
- name: Terraform min/max versions | ||
id: minMax | ||
uses: clowdhaus/terraform-min-max@main | ||
outputs: | ||
minVersion: ${{ steps.minMax.outputs.minVersion }} | ||
maxVersion: ${{ steps.minMax.outputs.maxVersion }} | ||
|
||
- name: 'Terraform validate' | ||
uses: 'clouddrove/github-actions@v7.0' | ||
with: | ||
actions_subcommand: 'validate' | ||
tf_actions_working_dir: ./_example | ||
|
||
plan: | ||
name: 'terraform plan' | ||
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.3.4 | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: 'Terraform init' | ||
uses: 'clouddrove/github-actions@v7.0' | ||
- name: Install Terraform v${{ matrix.version }} | ||
uses: hashicorp/setup-terraform@v1 | ||
with: | ||
actions_subcommand: 'init' | ||
tf_actions_working_dir: ./_example | ||
terraform_version: ${{ matrix.version }} | ||
|
||
- name: 'Configure AWS Credentials' | ||
uses: clouddrove/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }} | ||
aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }} | ||
aws-region: us-east-2 | ||
aws-region: eu-west-1 | ||
|
||
- name: 'Terraform plan' | ||
uses: 'clouddrove/github-actions@v7.0' | ||
- name: Init & validate v${{ matrix.version }} | ||
run: | | ||
cd ${{ matrix.directory }} | ||
terraform init | ||
terraform validate | ||
terraform plan -input=false -no-color | ||
- name: tflint | ||
uses: reviewdog/action-tflint@master | ||
with: | ||
actions_subcommand: 'plan' | ||
tf_actions_working_dir: ./_example | ||
|
||
pre-commit: | ||
name: 'Pre-Commit' | ||
needs: | ||
- fmt | ||
- plan | ||
- validate | ||
tflint_version: v0.29.0 | ||
github_token: ${{ secrets.GITHUB }} | ||
working_directory: ${{ matrix.directory }} | ||
fail_on_error: 'true' | ||
filter_mode: 'nofilter' | ||
flags: '--module' | ||
|
||
format: | ||
name: Check code format | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 'Checkout' | ||
uses: actions/checkout@v2.3.4 | ||
needs: versionExtract | ||
|
||
- name: 'Install Tflint' | ||
run: | | ||
curl https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash | ||
- name: 'Pre-Commit 🔎' | ||
uses: pre-commit/action@v2.0.3 | ||
continue-on-error: true | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: 'Slack Notification' | ||
uses: clouddrove/action-slack@v2 | ||
- name: Install Terraform v${{ needs.versionExtract.outputs.maxVersion }} | ||
uses: hashicorp/setup-terraform@v1 | ||
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() | ||
terraform_version: ${{ needs.versionExtract.outputs.maxVersion }} | ||
|
||
- name: Check Terraform format changes | ||
run: terraform fmt --recursive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
# Terraform version | ||
terraform { | ||
required_version = ">= 0.14.0" | ||
required_version = ">= 1.3.6" | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 3.1.15" | ||
version = ">= 4.48.0" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters