diff --git a/README.md b/README.md
index 3c50656..9c8dd37 100644
--- a/README.md
+++ b/README.md
@@ -336,7 +336,7 @@ should migrate to this module as a drop-in replacement to benefit from new featu
| Name | Version |
|------|---------|
-| [aws](#provider\_aws) | 4.32.0 |
+| [aws](#provider\_aws) | 4.38.0 |
## Modules
@@ -390,6 +390,7 @@ No modules.
| [filename](#input\_filename) | The path to the function's deployment package within the local filesystem. If defined, The s3\_-prefixed options and image\_uri cannot be used. | `string` | `null` | no |
| [function\_name](#input\_function\_name) | A unique name for your Lambda Function. | `string` | n/a | yes |
| [handler](#input\_handler) | The function entrypoint in your code. | `string` | `""` | no |
+| [iam\_role\_name](#input\_iam\_role\_name) | Override the name of the IAM role for the function. Otherwise the default will be your function name with the region as a suffix. | `string` | `null` | no |
| [ignore\_external\_function\_updates](#input\_ignore\_external\_function\_updates) | Ignore updates to your Lambda function executed externally to the Terraform lifecycle. Set this to `true` if you're using CodeDeploy, aws CLI or other external tools to update your Lambda function code. | `bool` | `false` | no |
| [image\_config](#input\_image\_config) | The Lambda OCI [image configurations](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function#image_config) block with three (optional) arguments:
- *entry\_point* - The ENTRYPOINT for the docker image (type `list(string)`).
- *command* - The CMD for the docker image (type `list(string)`).
- *working\_directory* - The working directory for the docker image (type `string`). | `any` | `{}` | no |
| [image\_uri](#input\_image\_uri) | The ECR image URI containing the function's deployment package. Conflicts with filename, s3\_bucket, s3\_key, and s3\_object\_version. | `string` | `null` | no |
diff --git a/docs/deployment/part2.md b/docs/deployment/part2.md
index 8031f14..c8d9db8 100644
--- a/docs/deployment/part2.md
+++ b/docs/deployment/part2.md
@@ -9,7 +9,7 @@
| Name | Version |
|------|---------|
-| [aws](#provider\_aws) | 4.33.0 |
+| [aws](#provider\_aws) | 4.38.0 |
## Modules
diff --git a/docs/part2.md b/docs/part2.md
index 0eccdd5..c3730d6 100644
--- a/docs/part2.md
+++ b/docs/part2.md
@@ -9,7 +9,7 @@
| Name | Version |
|------|---------|
-| [aws](#provider\_aws) | 4.32.0 |
+| [aws](#provider\_aws) | 4.38.0 |
## Modules
@@ -63,6 +63,7 @@ No modules.
| [filename](#input\_filename) | The path to the function's deployment package within the local filesystem. If defined, The s3\_-prefixed options and image\_uri cannot be used. | `string` | `null` | no |
| [function\_name](#input\_function\_name) | A unique name for your Lambda Function. | `string` | n/a | yes |
| [handler](#input\_handler) | The function entrypoint in your code. | `string` | `""` | no |
+| [iam\_role\_name](#input\_iam\_role\_name) | Override the name of the IAM role for the function. Otherwise the default will be your function name with the region as a suffix. | `string` | `null` | no |
| [ignore\_external\_function\_updates](#input\_ignore\_external\_function\_updates) | Ignore updates to your Lambda function executed externally to the Terraform lifecycle. Set this to `true` if you're using CodeDeploy, aws CLI or other external tools to update your Lambda function code. | `bool` | `false` | no |
| [image\_config](#input\_image\_config) | The Lambda OCI [image configurations](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function#image_config) block with three (optional) arguments:
- *entry\_point* - The ENTRYPOINT for the docker image (type `list(string)`).
- *command* - The CMD for the docker image (type `list(string)`).
- *working\_directory* - The working directory for the docker image (type `string`). | `any` | `{}` | no |
| [image\_uri](#input\_image\_uri) | The ECR image URI containing the function's deployment package. Conflicts with filename, s3\_bucket, s3\_key, and s3\_object\_version. | `string` | `null` | no |
diff --git a/iam.tf b/iam.tf
index 8747a93..d9005e0 100644
--- a/iam.tf
+++ b/iam.tf
@@ -1,3 +1,7 @@
+locals {
+ iam_role_name = coalesce(var.iam_role_name, "${var.function_name}-${data.aws_region.current.name}")
+}
+
data "aws_iam_policy_document" "assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
@@ -10,7 +14,7 @@ data "aws_iam_policy_document" "assume_role_policy" {
}
resource "aws_iam_role" "lambda" {
- name = "${var.function_name}-${data.aws_region.current.name}"
+ name = local.iam_role_name
assume_role_policy = data.aws_iam_policy_document.assume_role_policy.json
}
diff --git a/modules/deployment/README.md b/modules/deployment/README.md
index ce7ecb1..336e25f 100644
--- a/modules/deployment/README.md
+++ b/modules/deployment/README.md
@@ -173,7 +173,7 @@ resource "aws_s3_bucket_object" "source" {
| Name | Version |
|------|---------|
-| [aws](#provider\_aws) | 4.33.0 |
+| [aws](#provider\_aws) | 4.38.0 |
## Modules
diff --git a/variables.tf b/variables.tf
index 3626ad0..671d50e 100644
--- a/variables.tf
+++ b/variables.tf
@@ -223,3 +223,9 @@ variable "vpc_config" {
subnet_ids = list(string)
})
}
+
+variable "iam_role_name" {
+ description = "Override the name of the IAM role for the function. Otherwise the default will be your function name with the region as a suffix."
+ default = null
+ type = string
+}