Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ There are 6 supported ways to attach IAM policies to IAM role used by Lambda Fun
1. `policy_json` - JSON string or heredoc, when `attach_policy_json = true`.
1. `policy_jsons` - List of JSON strings or heredoc, when `attach_policy_jsons = true` and `number_of_policy_jsons > 0`.
1. `policy` - ARN of existing IAM policy, when `attach_policy = true`.
1. `policies` - List of ARNs of existing IAM policies, when `attach_policies = true` and `number_of_policies > 0`.
1. `policies` - List of ARNs of existing IAM policies, when `attach_policies = true`.
1. `policy_statements` - Map of maps to define IAM statements which will be generated as IAM policy. Requires `attach_policy_statements = true`. See `examples/complete` for more information.
1. `assume_role_policy_statements` - Map of maps to define IAM statements which will be generated as IAM policy for assuming Lambda Function role (trust relationship). See `examples/complete` for more information.

Expand Down Expand Up @@ -814,7 +814,6 @@ No modules.
| <a name="input_maximum_event_age_in_seconds"></a> [maximum\_event\_age\_in\_seconds](#input\_maximum\_event\_age\_in\_seconds) | Maximum age of a request that Lambda sends to a function for processing in seconds. Valid values between 60 and 21600. | `number` | `null` | no |
| <a name="input_maximum_retry_attempts"></a> [maximum\_retry\_attempts](#input\_maximum\_retry\_attempts) | Maximum number of times to retry when the function returns an error. Valid values between 0 and 2. Defaults to 2. | `number` | `null` | no |
| <a name="input_memory_size"></a> [memory\_size](#input\_memory\_size) | Amount of memory in MB your Lambda Function can use at runtime. Valid value between 128 MB to 10,240 MB (10 GB), in 64 MB increments. | `number` | `128` | no |
| <a name="input_number_of_policies"></a> [number\_of\_policies](#input\_number\_of\_policies) | Number of policies to attach to IAM role for Lambda Function | `number` | `0` | no |
| <a name="input_number_of_policy_jsons"></a> [number\_of\_policy\_jsons](#input\_number\_of\_policy\_jsons) | Number of policies JSON to attach to IAM role for Lambda Function | `number` | `0` | no |
| <a name="input_package_type"></a> [package\_type](#input\_package\_type) | The Lambda deployment package type. Valid options: Zip or Image | `string` | `"Zip"` | no |
| <a name="input_policies"></a> [policies](#input\_policies) | List of policy statements ARN to attach to Lambda Function role | `list(string)` | `[]` | no |
Expand Down
2 changes: 1 addition & 1 deletion examples/alias/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module "lambda_function" {
policies = [
"arn:aws:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole",
]
number_of_policies = 1


allowed_triggers = {
APIGatewayAny = {
Expand Down
6 changes: 3 additions & 3 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ module "lambda_function" {
attach_policy = true
policy = "arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess"

attach_policies = true
policies = ["arn:aws:iam::aws:policy/AWSXrayReadOnlyAccess"]
number_of_policies = 1
attach_policies = true
policies = ["arn:aws:iam::aws:policy/AWSXrayReadOnlyAccess"]


attach_policy_statements = true
policy_statements = {
Expand Down
3 changes: 1 addition & 2 deletions examples/event-source-mapping/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ module "lambda_function" {
}
}

attach_policies = true
number_of_policies = 3
attach_policies = true

policies = [
"arn:aws:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole",
Expand Down
12 changes: 6 additions & 6 deletions examples/multiple-regions/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ EOF
attach_policy = true
policy = "arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess"

attach_policies = true
policies = ["arn:aws:iam::aws:policy/AWSXrayReadOnlyAccess"]
number_of_policies = 1
attach_policies = true
policies = ["arn:aws:iam::aws:policy/AWSXrayReadOnlyAccess"]


attach_policy_statements = true
policy_statements = {
Expand Down Expand Up @@ -173,9 +173,9 @@ EOF
attach_policy = true
policy = "arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess"

attach_policies = true
policies = ["arn:aws:iam::aws:policy/AWSXrayReadOnlyAccess"]
number_of_policies = 1
attach_policies = true
policies = ["arn:aws:iam::aws:policy/AWSXrayReadOnlyAccess"]


attach_policy_statements = true
policy_statements = {
Expand Down
4 changes: 2 additions & 2 deletions iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,10 @@ resource "aws_iam_role_policy_attachment" "additional_one" {
######################################

resource "aws_iam_role_policy_attachment" "additional_many" {
count = local.create_role && var.attach_policies ? var.number_of_policies : 0
for_each = local.create_role && var.attach_policies ? toset(var.policies) : toset([])

role = aws_iam_role.lambda[0].name
policy_arn = var.policies[count.index]
policy_arn = each.value
}

###############################
Expand Down
5 changes: 0 additions & 5 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -610,11 +610,6 @@ variable "number_of_policy_jsons" {
default = 0
}

variable "number_of_policies" {
description = "Number of policies to attach to IAM role for Lambda Function"
type = number
default = 0
}

variable "attach_policy_statements" {
description = "Controls whether policy_statements should be added to IAM role for Lambda Function"
Expand Down
1 change: 0 additions & 1 deletion wrappers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ module "wrapper" {
maximum_event_age_in_seconds = try(each.value.maximum_event_age_in_seconds, var.defaults.maximum_event_age_in_seconds, null)
maximum_retry_attempts = try(each.value.maximum_retry_attempts, var.defaults.maximum_retry_attempts, null)
memory_size = try(each.value.memory_size, var.defaults.memory_size, 128)
number_of_policies = try(each.value.number_of_policies, var.defaults.number_of_policies, 0)
number_of_policy_jsons = try(each.value.number_of_policy_jsons, var.defaults.number_of_policy_jsons, 0)
package_type = try(each.value.package_type, var.defaults.package_type, "Zip")
policies = try(each.value.policies, var.defaults.policies, [])
Expand Down
Loading