I have Lambdas with Tag of Name=production.
I would like to get them using Terraform, looking at aws_lambda_function, I can only get single lambda by function_name
data "aws_lambda_function" "existing" {
function_name = var.function_name
}
CodePudding user response:
You can use the aws_resourcegroupstaggingapi_resources
to retrieve information for several AWS resources that don't have more specific data sources.
For your use case, considering Name=production
, you can use:
data "aws_resourcegroupstaggingapi_resources" "existing" {
resource_type_filters = ["lambda:function"]
tag_filter {
key = "Name"
values = ["production"]
}
}
output "arns" {
value = data.aws_resourcegroupstaggingapi_resources.existing.resource_tag_mapping_list.*.resource_arn
}
CodePudding user response:
There is no data source to get multiple lambda functions. You have to create your own custom data source for detailed information about multiple lambda functions.