Skip to content

Commit

Permalink
Merge pull request #4 from GSA/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
Brian Fitzwater - IDI-C authored Sep 27, 2019
2 parents b0e1d03 + f91b0f6 commit d521bf4
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 53 deletions.
38 changes: 31 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,27 @@ endif
export appenv := $(shell echo "$(environment)" | tr '[:upper:]' '[:lower:]')
export TF_VAR_appenv := $(appenv)

.PHONY: test deploy lint_handler test_handler build_handler release_handler plan_terraform apply_terraform clean
.PHONY: test deploy check lint_handler test_handler build_handler release_handler plan_terraform validate_terraform init_terraform apply_terraform apply_terraform_tests destroy_terraform_tests clean
test: test_handler plan_terraform

deploy: build_handler apply_terraform

check:
ifeq ($(strip $(backend_bucket)),)
@echo "backend_bucket must be provided"
@exit 1
endif
ifeq ($(strip $(TF_VAR_appenv)),)
@echo "TF_VAR_appenv must be provided"
@exit 1
else
@echo "appenv: $(TF_VAR_appenv)"
endif
ifeq ($(strip $(backend_key)),)
@echo "backend_key must be provided"
@exit 1
endif

lint_handler:
make -C handler lint

Expand All @@ -26,17 +42,25 @@ build_handler:
release_handler:
make -C handler release

plan_terraform:
make -C terraform plan
plan_terraform: validate_terraform
terraform plan
make -C tests plan

validate_terraform: init_terraform
terraform validate

init_terraform: check
[[ -d release ]] || mkdir release
[[ -e release/grace-inventory-lambda.zip ]] || touch release/grace-inventory-lambda.zip
terraform init -backend-config="bucket=$(backend_bucket)" -backend-config="key=$(backend_key)"

apply_terraform:
make -C terraform apply
apply_terraform: apply_terraform_tests

apply_terraform_tests:
make -C terraform/tests apply
make -C tests apply

destroy_terraform_tests:
make -C terraform/tests destroy
make -C tests destroy

clean:
make -C handler clean
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ download the binary release from Github or compile the handler locally.
```bash
mkdir -p release
cd release
curl -L https://github.com/GSA/grace-inventory/releases/download/v0.1.0/grace-inventory-lambda.zip -o grace-inventory-lambda.zip
curl -L https://github.com/GSA/grace-inventory/releases/download/v0.1.1/grace-inventory-lambda.zip -o grace-inventory-lambda.zip
cd ..
```

Expand Down Expand Up @@ -148,7 +148,7 @@ include the following in your root terraform module:

```
module "example_self" {
source = "github.com/GSA/grace-inventory/terraform"
source = "github.com/GSA/grace-inventory?ref=v0.1.1"
source_file = "../../release/grace-inventory-lambda.zip"
appenv = "environment"
project_name = "your-project"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ module "example_master" {
accounts_info = ""
source_file = "../../release/grace-inventory-lambda.zip"
appenv = "development"
//project_name = "grace"
project_name = "grace"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ module "example_mgmt_all" {
master_role_name = "AssumableRole"
source_file = "../../release/grace-inventory-lambda.zip"
appenv = "development"
//project_name = "grace"
project_name = "grace"
}
8 changes: 8 additions & 0 deletions examples/example-self.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// The default behavior is to inventory only the account the lambda function
// is installed in (i.e. accounts_info = "self"
module "example_self" {
source = "github.com/GSA/grace-inventory/terraform"
source_file = "../../release/grace-inventory-lambda.zip"
appenv = "development"
project_name = "grace"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 0 additions & 32 deletions terraform/Makefile

This file was deleted.

8 changes: 0 additions & 8 deletions terraform/examples/example-self.tf

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ provider "aws" {
// if accounts_info = "" and master_account_id and master_role_name are set
// and the roles are assumable by the Lambda function's IAM role
module "integration_test" {
// source = "github.com/GSA/grace-inventory/terraform?ref=latest"
// source = "github.com/GSA/grace-inventory?ref=latest"
source = "../"
accounts_info = "self"
project_name = "grace"
appenv = var.appenv
master_account_id = var.master_account_id
master_role_name = var.master_role_name
tenant_role_name = var.tenant_role_name
source_file = "../../release/grace-inventory-lambda.zip"
source_file = "../release/grace-inventory-lambda.zip"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d521bf4

Please sign in to comment.