generated from GSA/grace-template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from GSA/parameterize_program
Parameterize program
- Loading branch information
Showing
20 changed files
with
102 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
terraform { | ||
required_version = ">= 0.12" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
resource "aws_lambda_function" "lambda_function" { | ||
filename = "${var.source_file}" | ||
function_name = "${local.app_name}" | ||
filename = var.source_file | ||
function_name = local.app_name | ||
description = "Creates report of AWS Services in Organization accounts and saves to Excel spreadsheet in S3 bucket" | ||
role = "${aws_iam_role.iam_role.arn}" | ||
role = aws_iam_role.iam_role.arn | ||
handler = "grace-inventory-lambda" | ||
source_code_hash = "${filesha256(var.source_file)}" | ||
kms_key_arn = "${aws_kms_key.kms_key.arn}" | ||
source_code_hash = filesha256(var.source_file) | ||
kms_key_arn = aws_kms_key.kms_key.arn | ||
runtime = "go1.x" | ||
timeout = 900 | ||
|
||
environment { | ||
variables = { | ||
accounts_info = "${var.accounts_info}" | ||
kms_key_id = "${aws_kms_key.kms_key.key_id}" | ||
master_role_name = "${var.master_role_name}" | ||
master_account_id = "${var.master_account_id}" | ||
accounts_info = var.accounts_info | ||
kms_key_id = aws_kms_key.kms_key.key_id | ||
master_role_name = var.master_role_name | ||
master_account_id = var.master_account_id | ||
// organizational_units = "${organizational_units}" | ||
regions = "${var.regions}" | ||
s3_bucket = "${aws_s3_bucket.bucket.bucket}" | ||
tenant_role_name = "${var.tenant_role_name}" | ||
regions = var.regions | ||
s3_bucket = aws_s3_bucket.bucket.bucket | ||
tenant_role_name = var.tenant_role_name | ||
} | ||
} | ||
} | ||
|
||
resource "aws_lambda_permission" "lambda_permission" { | ||
statement_id = "AllowExecutionFromCloudWatch" | ||
action = "lambda:InvokeFunction" | ||
function_name = "${aws_lambda_function.lambda_function.function_name}" | ||
function_name = aws_lambda_function.lambda_function.function_name | ||
principal = "events.amazonaws.com" | ||
source_arn = "${aws_cloudwatch_event_rule.cwe_rule.arn}" | ||
source_arn = aws_cloudwatch_event_rule.cwe_rule.arn | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
terraform { | ||
backend "s3" { | ||
region = "us-east-1" | ||
} | ||
data "aws_caller_identity" "current" { | ||
} | ||
|
||
provider "aws" {} | ||
|
||
data "aws_caller_identity" "current" {} | ||
|
||
locals { | ||
app_name = "grace-${var.appenv}-inventory" | ||
account_id = "${data.aws_caller_identity.current.account_id}" | ||
logging_bucket = "${"${var.appenv}" == "integration-testing" ? "grace-development-access-logs" : "grace-${var.appenv}-access-logs"}" | ||
app_name = "${var.project_name}-${var.appenv}-inventory" | ||
account_id = data.aws_caller_identity.current.account_id | ||
logging_bucket = var.appenv == "integration-testing" ? "grace-development-access-logs" : "${var.project_name}-${var.appenv}-access-logs" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
output "lambda_function_arn" { | ||
value = "${aws_lambda_function.lambda_function.arn}" | ||
value = aws_lambda_function.lambda_function.arn | ||
description = "The Amazon Resource Name (ARN) identifying the Lambda Function" | ||
} | ||
|
||
output "lambda_function_last_modified" { | ||
value = "${aws_lambda_function.lambda_function.last_modified}" | ||
value = aws_lambda_function.lambda_function.last_modified | ||
description = "The date this resource was last modified" | ||
} | ||
|
||
output "lambda_function_kms_key_arn" { | ||
value = "${aws_lambda_function.lambda_function.kms_key_arn}" | ||
value = aws_lambda_function.lambda_function.kms_key_arn | ||
description = "The ARN for the KMS encryption key" | ||
} | ||
|
||
output "s3_bucket_id" { | ||
value = "${aws_s3_bucket.bucket.id}" | ||
value = aws_s3_bucket.bucket.id | ||
description = "The name of the S3 bucket where inventry reports are saved" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
variable "appenv" { | ||
type = "string" | ||
type = string | ||
description = "(optional) The environment in which the script is running (development | test | production)" | ||
default = "integration-testing" | ||
} | ||
|
||
variable "tenant_role_name" { | ||
type = "string" | ||
type = string | ||
description = "(optional) Role assumed by lambda function to query tenant accounts" | ||
default = "OrganizationAccountAccessRole" | ||
} | ||
|
||
variable "master_role_name" { | ||
type = "string" | ||
type = string | ||
description = "(optional) Role assumed by lambda function to query organizations in Master Payer account" | ||
default = "" | ||
} | ||
|
||
variable "master_account_id" { | ||
type = "string" | ||
type = string | ||
description = "(optional) Account ID of AWS Master Payer Account" | ||
default = "" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
terraform { | ||
required_version = ">= 0.12" | ||
} |
Oops, something went wrong.