Skip to content

Commit

Permalink
[*/Makefile] include Makefile.* (cloudposse#92)
Browse files Browse the repository at this point in the history
* Update makefiles with include

* Use native terraform with tfenv
  • Loading branch information
osterman authored and joshmyers committed Jan 14, 2019
1 parent 11a275c commit 2c9b53e
Show file tree
Hide file tree
Showing 27 changed files with 94 additions and 33 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ We recommend that you start with your clean `terraform-root-module` repo. Then s
Here's a good example of a `Makefile` for a terraform project:

```
-include Makefile.*
## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@
## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ introduction: |-
Here's a good example of a `Makefile` for a terraform project:
```
-include Makefile.*
## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@
## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/account-dns/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/account-settings/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/accounts/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/acm-cloudfront/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/acm/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
21 changes: 15 additions & 6 deletions aws/artifacts/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
plan:
@tfenv terraform $@
-include Makefile.*

apply:
@tfenv terraform $@
## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || terraform $@

destroy:
@tfenv terraform $@
## Clean up the project
clean:
rm -rf .terraform *.tfstate*

## Pass arguments through to terraform which require remote state
apply console destroy graph plan output providers show: init
terraform $@

## Pass arguments through to terraform which do not require remote state
get fmt validate version:
terraform $@
4 changes: 3 additions & 1 deletion aws/audit-cloudtrail/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/backing-services/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/bootstrap/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/chamber/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/cloudtrail/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/ecr/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/eks-backing-services-peering/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/eks/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/iam/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/kops-aws-platform/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/kops/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean: kops/clean
Expand Down
4 changes: 3 additions & 1 deletion aws/organization/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/root-dns/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/root-iam/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/ses/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
-include Makefile.*
-include .terraform/modules/**/Makefile.ses

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
6 changes: 4 additions & 2 deletions aws/tfstate-backend/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
-include Makefile.*

## Initialize the terraform state backend
init:
@aws s3 ls s3://${TF_BUCKET}/tfstate-backend/terraform.tfstate > /dev/null || \
scripts/$@.sh
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Destroy the configuration (only works if `force_destroy=true`)
destroy:
Expand All @@ -17,7 +19,7 @@ clean:
rm -rf .terraform *.tfstate*

## Pass arguments through to terraform which require remote state
apply console destroy graph plan output providers show: init
apply console graph plan output providers show: init
terraform $@

## Pass arguments through to terraform which do not require remote state
Expand Down
4 changes: 3 additions & 1 deletion aws/users/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down
4 changes: 3 additions & 1 deletion aws/vpc-peering/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-include Makefile.*

## Initialize terraform remote state
init:
[ -f .terraform/terraform.tfstate ] || init-terraform
[ -f .terraform/terraform.tfstate ] || terraform $@

## Clean up the project
clean:
Expand Down

0 comments on commit 2c9b53e

Please sign in to comment.