Skip to content

Commit

Permalink
feat: Allows tags to be provided only to the function (#508)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Carey <[email protected]>
  • Loading branch information
mike-carey and mike-carey authored Oct 27, 2023
1 parent e2500c0 commit 610d602
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@ No modules.
| <a name="input_file_system_arn"></a> [file\_system\_arn](#input\_file\_system\_arn) | The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system. | `string` | `null` | no |
| <a name="input_file_system_local_mount_path"></a> [file\_system\_local\_mount\_path](#input\_file\_system\_local\_mount\_path) | The path where the function can access the file system, starting with /mnt/. | `string` | `null` | no |
| <a name="input_function_name"></a> [function\_name](#input\_function\_name) | A unique name for your Lambda Function | `string` | `""` | no |
| <a name="input_function_tags"></a> [function\_tags](#input\_function\_tags) | A map of tags to assign only to the lambda function | `map(string)` | `{}` | no |
| <a name="input_handler"></a> [handler](#input\_handler) | Lambda Function entrypoint in your code | `string` | `""` | no |
| <a name="input_hash_extra"></a> [hash\_extra](#input\_hash\_extra) | The string to add into hashing function. Useful when building same source path for different functions. | `string` | `""` | no |
| <a name="input_ignore_source_code_hash"></a> [ignore\_source\_code\_hash](#input\_ignore\_source\_code\_hash) | Whether to ignore changes to the function's source code hash. Set to true if you manage infrastructure and code deployments separately. | `bool` | `false` | no |
Expand Down
4 changes: 4 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ module "lambda_function" {
delete = "20m"
}

function_tags = {
Language = "python"
}

tags = {
Module = "lambda1"
}
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ resource "aws_lambda_function" "this" {
delete = try(var.timeouts.delete, null)
}

tags = var.tags
tags = merge(var.tags, var.function_tags)

depends_on = [
null_resource.archive,
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ variable "tags" {
default = {}
}

variable "function_tags" {
description = "A map of tags to assign only to the lambda function"
type = map(string)
default = {}
}

variable "s3_object_tags" {
description = "A map of tags to assign to S3 bucket object."
type = map(string)
Expand Down
1 change: 1 addition & 0 deletions wrappers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module "wrapper" {
vpc_subnet_ids = try(each.value.vpc_subnet_ids, var.defaults.vpc_subnet_ids, null)
vpc_security_group_ids = try(each.value.vpc_security_group_ids, var.defaults.vpc_security_group_ids, null)
tags = try(each.value.tags, var.defaults.tags, {})
function_tags = try(each.value.function_tags, var.defaults.function_tags, {})
s3_object_tags = try(each.value.s3_object_tags, var.defaults.s3_object_tags, {})
s3_object_tags_only = try(each.value.s3_object_tags_only, var.defaults.s3_object_tags_only, false)
package_type = try(each.value.package_type, var.defaults.package_type, "Zip")
Expand Down

0 comments on commit 610d602

Please sign in to comment.