diff --git a/.circleci/config.yml b/.circleci/config.yml index 4101b08..ee08a24 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,7 +24,7 @@ jobs: command: curl -L -o /tmp/tflint.zip https://github.com/wata727/tflint/releases/download/v0.9.2/tflint_linux_amd64.zip && unzip /tmp/tflint.zip -d /usr/local/bin - run: name: Check Terraform configurations with tflint - command: tflint + command: find . -name ".terraform" -prune -o -type f -name "*.tf" -exec dirname {} \;|sort -u | while read m; do (cd "$m" && tflint --ignore-rule=terraform_module_pinned_source && echo "√ $m") || exit 1 ; done lint_handler: environment: AWS_DEFAULT_REGION: us-east-1 diff --git a/README.md b/README.md index 3c9eb77..ed9d4dd 100644 --- a/README.md +++ b/README.md @@ -148,8 +148,10 @@ include the following in your root terraform module: ``` module "example_self" { - source = "github.com/GSA/grace-inventory/terraform" - source_file = "../../release/grace-inventory-lambda.zip" + source = "github.com/GSA/grace-inventory/terraform" + source_file = "../../release/grace-inventory-lambda.zip" + appenv = "environment" + project_name = "your-project" } ``` @@ -165,14 +167,15 @@ See the [examples](terraform/examples) directory for more examples. | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| accounts\_info | \(optional\) Determines which accounts to parse. Can be "self", comma delimited list of Account IDs or an S3 URI containing JSON output of `aws organizations list-accounts`. If empty, tries to query accounts with `organizations:ListAccounts` | string | `"self"` | no | +| source\_file | \(optional\) full or relative path to zipped binary of lambda handler | string | `"../release/grace-inventory-lambda.zip"` | no | | appenv | \(optional\) The environment in which the script is running \(development \| test \| production\) | string | `"development"` | no | +| project_name | \(required\) project name \(e.g. grace, fcs, fas, etc.\). Used as prefix for AWS S3 bucket name | string | `"grace"` | yes | +| accounts\_info | \(optional\) Determines which accounts to parse. Can be "self", comma delimited list of Account IDs or an S3 URI containing JSON output of `aws organizations list-accounts`. If empty, tries to query accounts with `organizations:ListAccounts` | string | `"self"` | no | | master\_account\_id | \(optional\) Account ID of AWS Master Payer Account | string | `""` | no | | master\_role\_name | \(optional\) Role assumed by lambda function to query organizations in Master Payer account | string | `""` | no | | organizational\_units | \(optional\) comma delimited list of organizational units to query for accounts. If set it will only query accounts in those organizational units | string | `""` | no | | regions | \(optional\) Comma delimited list of AWS regions to inventory | string | `"us-east-1,us-east-2,us-west-1,us-west-2"` | no | | schedule\_expression | \(optional\) Cloudwatch schedule expression for when to run inventory | string | `"cron(5 3 ? * MON-FRI *)"` | no | -| source\_file | \(optional\) full or relative path to zipped binary of lambda handler | string | `"../release/grace-inventory-lambda.zip"` | no | | tenant\_role\_name | \(optional\) Role assumed by lambda function to query tenant accounts | string | `"OrganizationAccountAccessRole"` | no | [top](#top) diff --git a/terraform/backend.tfvars.example b/terraform/backend.tfvars.example deleted file mode 100644 index 87e51c1..0000000 --- a/terraform/backend.tfvars.example +++ /dev/null @@ -1,3 +0,0 @@ -bucket = "terraform-backend-bucket" - -key = "grace_inventory_lambda.tfstate" diff --git a/terraform/cloudwatch.tf b/terraform/cloudwatch.tf index 041a67c..1cf2693 100644 --- a/terraform/cloudwatch.tf +++ b/terraform/cloudwatch.tf @@ -1,11 +1,12 @@ resource "aws_cloudwatch_event_rule" "cwe_rule" { - name = "${local.app_name}" + name = local.app_name description = "Triggers GRACE service inventory reporting Lambda function according to schedule expression" - schedule_expression = "${var.schedule_expression}" + schedule_expression = var.schedule_expression } resource "aws_cloudwatch_event_target" "cwe_target" { - rule = "${aws_cloudwatch_event_rule.cwe_rule.name}" - target_id = "${local.app_name}" - arn = "${aws_lambda_function.lambda_function.arn}" + rule = aws_cloudwatch_event_rule.cwe_rule.name + target_id = local.app_name + arn = aws_lambda_function.lambda_function.arn } + diff --git a/terraform/examples/example-master.tf b/terraform/examples/example-master.tf index 385e263..dc137d9 100644 --- a/terraform/examples/example-master.tf +++ b/terraform/examples/example-master.tf @@ -5,4 +5,6 @@ module "example_master" { source = "github.com/GSA/grace-inventory/terraform" accounts_info = "" source_file = "../../release/grace-inventory-lambda.zip" + appenv = "development" + //project_name = "grace" } diff --git a/terraform/examples/example-mgmt-all.tf b/terraform/examples/example-mgmt-all.tf index d7d4a13..362ec0f 100644 --- a/terraform/examples/example-mgmt-all.tf +++ b/terraform/examples/example-mgmt-all.tf @@ -8,4 +8,6 @@ module "example_mgmt_all" { master_account_id = "111111111111" master_role_name = "AssumableRole" source_file = "../../release/grace-inventory-lambda.zip" + appenv = "development" + //project_name = "grace" } diff --git a/terraform/examples/example-self.tf b/terraform/examples/example-self.tf index e59250d..c74218a 100644 --- a/terraform/examples/example-self.tf +++ b/terraform/examples/example-self.tf @@ -3,4 +3,6 @@ module "example_self" { source = "github.com/GSA/grace-inventory/terraform" source_file = "../../release/grace-inventory-lambda.zip" + appenv = "development" + //project_name = "grace" } diff --git a/terraform/examples/versions.tf b/terraform/examples/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/terraform/examples/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/terraform/iam.tf b/terraform/iam.tf index 4a05018..8213181 100644 --- a/terraform/iam.tf +++ b/terraform/iam.tf @@ -1,5 +1,5 @@ resource "aws_iam_role" "iam_role" { - name = "${local.app_name}" + name = local.app_name description = "Role for GRACE Inventory Lambda function" assume_role_policy = <