This repository has been archived by the owner on Jun 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New feature - Additional trust relashionships (#59)
* Adding cloudwatch event role for trust relationship lambda * Adding assume_roles * Adding few comments and finalizing * Removing useless comments * Updating README.md + adding tests * Update variables.tf * Update iam.tf * Update README.md * Update main.tf
- Loading branch information
1 parent
ace2bc9
commit f9ff6ee
Showing
5 changed files
with
122 additions
and
1 deletion.
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 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,5 @@ | ||
def lambda_handler(event, context): | ||
if event['pass']: | ||
return True | ||
else: | ||
raise Exception('oh no') |
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,106 @@ | ||
terraform { | ||
backend "local" { | ||
path = "terraform.tfstate" | ||
} | ||
} | ||
|
||
provider "aws" { | ||
region = "eu-west-1" | ||
} | ||
|
||
resource "random_id" "name" { | ||
byte_length = 6 | ||
prefix = "terraform-aws-lambda-policy-" | ||
} | ||
|
||
resource "aws_sqs_queue" "test" { | ||
name = random_id.name.hex | ||
} | ||
|
||
data "aws_iam_policy_document" "computed" { | ||
statement { | ||
effect = "Allow" | ||
|
||
actions = [ | ||
"sqs:SendMessage", | ||
] | ||
|
||
resources = [ | ||
aws_sqs_queue.test.arn, | ||
] | ||
} | ||
} | ||
|
||
data "aws_iam_policy_document" "known" { | ||
statement { | ||
effect = "Deny" | ||
|
||
actions = [ | ||
"sqs:SendMessage", | ||
] | ||
|
||
resources = [ | ||
"*", | ||
] | ||
} | ||
} | ||
|
||
module "lambda_with_computed_policy_add_trust_relationships" { | ||
source = "../../" | ||
|
||
function_name = "${random_id.name.hex}-computed" | ||
description = "Test attaching policy with additional trust relationships in terraform-aws-lambda" | ||
handler = "lambda.lambda_handler" | ||
runtime = "python3.6" | ||
|
||
source_path = "${path.module}/lambda.py" | ||
|
||
trusted_entities = ["events.amazonaws.com"] | ||
|
||
policy = { | ||
json = data.aws_iam_policy_document.computed.json | ||
} | ||
} | ||
|
||
|
||
module "lambda_with_known_policy_add_trust_relationships" { | ||
source = "../../" | ||
|
||
function_name = "${random_id.name.hex}-known" | ||
description = "Test attaching policy with additional trust relationships in terraform-aws-lambda" | ||
handler = "lambda.lambda_handler" | ||
runtime = "python3.6" | ||
|
||
source_path = "${path.module}/lambda.py" | ||
|
||
trusted_entities = ["events.amazonaws.com"] | ||
|
||
policy = { | ||
json = data.aws_iam_policy_document.known.json | ||
} | ||
} | ||
|
||
|
||
module "lambda_without_policy_add_trust_relationships" { | ||
source = "../../" | ||
|
||
function_name = "${random_id.name.hex}-without" | ||
description = "Test attaching policy with additional trust relationships in terraform-aws-lambda" | ||
handler = "lambda.lambda_handler" | ||
runtime = "python3.6" | ||
|
||
source_path = "${path.module}/lambda.py" | ||
|
||
trusted_entities = ["events.amazonaws.com"] | ||
} | ||
|
||
module "lambda_without_policy_without_added_trust_relationships" { | ||
source = "../../" | ||
|
||
function_name = "${random_id.name.hex}-without" | ||
description = "Test attaching policy with additional trust relationships in terraform-aws-lambda" | ||
handler = "lambda.lambda_handler" | ||
runtime = "python3.6" | ||
|
||
source_path = "${path.module}/lambda.py" | ||
} |
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