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

Add support for Terraform 0.14 #262

Merged
merged 15 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,14 @@ Available targets:
slack/notify/deploy Send notification to slack using "deploy" template
template/build Create $OUT file by building it from $IN template file
template/deps Install dependencies
terraform/bump-tf-12-min-version Rewrite versions.tf to bump modules with minimum core version of '0.12.x' to '>= 0.12.26'
terraform/get-modules Ensure all modules can be fetched
terraform/get-plugins Ensure all plugins can be fetched
terraform/install Install terraform
terraform/lint Lint check Terraform
terraform/remove-upper-bound Rewrite versions.tf to remove upper bound for terraform core version constraint (like this ">= 0.12.0, < 0.14.0")
terraform/rewrite-module-source Rewrite the *.tf files to use registry notation for modules sources
terraform/rewrite-required-providers Rewrite versions.tf to update existing configuration to add an explicit source attribute for each provider
terraform/upgrade-modules Upgrade all terraform module sources
terraform/validate Basic terraform sanity check
travis/docker-login Login into docker hub
Expand Down
2 changes: 2 additions & 0 deletions docs/targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,14 @@ Available targets:
slack/notify/deploy Send notification to slack using "deploy" template
template/build Create $OUT file by building it from $IN template file
template/deps Install dependencies
terraform/bump-tf-12-min-version Rewrite versions.tf to bump modules with minimum core version of '0.12.x' to '>= 0.12.26'
terraform/get-modules Ensure all modules can be fetched
terraform/get-plugins Ensure all plugins can be fetched
terraform/install Install terraform
terraform/lint Lint check Terraform
terraform/remove-upper-bound Rewrite versions.tf to remove upper bound for terraform core version constraint (like this ">= 0.12.0, < 0.14.0")
terraform/rewrite-module-source Rewrite the *.tf files to use registry notation for modules sources
terraform/rewrite-required-providers Rewrite versions.tf to update existing configuration to add an explicit source attribute for each provider
terraform/upgrade-modules Upgrade all terraform module sources
terraform/validate Basic terraform sanity check
travis/docker-login Login into docker hub
Expand Down
24 changes: 23 additions & 1 deletion modules/terraform/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,34 @@ terraform/upgrade-modules:

## Rewrite the *.tf files to use registry notation for modules sources
terraform/rewrite-module-source:
@sed -i -E 's,"git::https://github.com/(.*?)/terraform-([^-]*?)-(.*?).git\?ref=tags/(.*?)","\1/\3/\2"\n version = "\4",g' $$(find . -type f -name '*.tf')
@sed -i -E 's,\s*source\s+=\s+"git::https://github.com/(.*?)/terraform-([^-]*?)-(.*?).git\?ref=(tags/)?(.*?)", source = "\1/\3/\2"\n version = "\5",g' $$(find . -type f -not -name context.tf -name '*.tf')
@$(TERRAFORM) fmt .
@$(TERRAFORM) fmt examples/complete

terraform/rewrite-readme-source:
@sed -i -E 's,^(\s*)source\s+=\s+"git::https://github.com/(.*?)/terraform-([^-]*?)-(.*?).git\?ref=(tags/)?master",\1source = "\2/\4/\3"\n\1# Cloud Posse recommends pinning module to a specific version\n\1# version = "x.x.x",g' README.yaml

## Rewrite versions.tf to remove upper bound for terraform core version constraint (like this ">= 0.12.0, < 0.14.0")
terraform/remove-upper-bound:
@sed -i -E 's,required_version\s*\=\s*\"(.*?)(\,\s*<.*)",required_version = "\1",g' $$(find . -type f -name 'versions.tf')
@$(TERRAFORM) fmt .
@$(TERRAFORM) fmt examples/complete

## Rewrite versions.tf to bump modules with minimum core version of '0.12.x' to '>= 0.12.26'
terraform/bump-tf-12-min-version:
@sed -i -E 's,required_version\s*\=\s*\"(\~>|>\=)\s?(0\.12\.0)\",required_version = ">= 0.12.26",g' $$(find . -type f -name 'versions.tf')
Nuru marked this conversation as resolved.
Show resolved Hide resolved
@$(TERRAFORM) fmt .
@$(TERRAFORM) fmt examples/complete

## Rewrite versions.tf to update existing configuration to add an explicit source attribute for each provider
terraform/rewrite-required-providers:
Nuru marked this conversation as resolved.
Show resolved Hide resolved
@KEEP_VERSION=$(grep -Eo 'required_version\s*=\s*"(.*)"' versions.tf | cut -d '"' -f2)
@terraform-0.13 0.13upgrade -yes ./
Nuru marked this conversation as resolved.
Show resolved Hide resolved
@terraform-0.13 0.13upgrade -yes examples/complete
@sed -i -E 's,(required_version\s*\=\s*\")(.*)(\"),\1'"$KEEP_VERSION"'\3,g' $$(find . -type f -name 'versions.tf')
@$(TERRAFORM) fmt .
@$(TERRAFORM) fmt examples/complete

terraform/v14-rewrite: TERRAFORM = terraform-0.13
terraform/v14-rewrite: terraform/remove-upper-bound terraform/rewrite-module-source terraform/rewrite-readme-source terraform/bump-tf-12-min-version terraform/rewrite-required-providers
git diff --no-patch --exit-code README.yaml || $(MAKE) readme