imfreedom/bamboo-terraform

Add a clean target and setup remote state
draft
2019-05-27, Gary Kramlich
40553e90cced
Parents 16d5b93c82a0
Children a70f5ef491c9
Add a clean target and setup remote state
  • +16 -10
    Makefile
  • +14 -0
    state.tf
  • --- a/Makefile Sun May 26 23:45:17 2019 -0500
    +++ b/Makefile Mon May 27 04:24:07 2019 -0500
    @@ -1,27 +1,29 @@
    -NODE=
    -PLAN_LIMIT=$(LIMIT:%= -target=%)
    +NODE =
    +PLAN_LIMIT = $(LIMIT:%= -target=%)
    TFARGS = -var-file nodes/$(NODE).tfvars
    +PARALLELISM := 4
    all: plan
    -plan: _require_node
    - terraform plan -parallelism=1 -out $(NODE).tfplan $(TFARGS) $(PLAN_LIMIT)
    +plan: _require_node _state
    + terraform plan -parallelism=$(PARALLELISM) -out $(NODE).tfplan $(TFARGS) $(PLAN_LIMIT)
    -showplan: _require_node
    +showplan: _require_node _state
    terraform showplan $(NODE).tfplan
    -destroy: _require_node
    +destroy: _require_node _state
    terraform plan -destroy -out $(NODE).tfplan $(TFARGS)
    -apply: _require_node
    +apply: _require_node _state
    terraform apply -input=true $(NODE).tfplan
    rm $(NODE).tfplan
    -refresh: _require_node
    +refresh: _require_node _state
    terraform refresh $(TFARGS)
    -showplan: _require_node
    - terraform show $(NODE).tfplan
    +clean:
    + rm -f *.tfplan*
    + rm -f *.tfstate*
    _require_node: nodes/$(NODE).tfvars
    $(warning *)
    @@ -30,6 +32,10 @@
    $(warning *)
    $(warning *)
    +_state: _require_node
    + rm -f terraform.tfstate
    + terraform init --backend-config="key=$(NODE).tfstate"
    +
    nodes/$(NODE).tfvars:
    @echo unknown node \"$(NODE)\"
    @exit 1
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/state.tf Mon May 27 04:24:07 2019 -0500
    @@ -0,0 +1,14 @@
    +terraform {
    + backend "s3" {
    + region = "main"
    + bucket = "terraform"
    + endpoint = "https://data.imfreedom.org"
    + force_path_style = true
    + skip_requesting_account_id = true
    + skip_credentials_validation = true
    + skip_get_ec2_platforms = true
    + skip_metadata_api_check = false
    + skip_region_validation = true
    + }
    +}
    +