Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ######### Here in main.tf we use module to create lambda function and invoke it:
- module "get_params" {
- source = "../../modules/lambda"
- file_name = module.get_params_archive.path
- lambda_function_file_name = "get_params"
- function_name = "get_params"
- invocation = "true"
- environment = merge(map(
- "project", local.project,
- "query", "[ \"key1\", \"key2\" ]"
- ))
- }
- ######### This is in "../../modules/lambda" files, shortened:
- ### the function creation
- resource "aws_lambda_function" "this" {
- filename = var.file_name
- function_name = local.name
- ...
- }
- ### invocation (var.creation is true)
- data "aws_lambda_invocation" "this" {
- count = var.invocation == "true" && var.creation == "true" ? 1 : 0
- function_name = aws_lambda_function.this.function_name
- input = <<JSON
- {
- "Name": "Invocation"
- }
- JSON
- }
- ### output of the module
- output "result_map" {
- description = "if result is a map"
- value = data.aws_lambda_invocation.this.*.result_map
- }
- ######### return back to the main code: here's how I get the output to check we have at least something and the lambda works :
- output "out_params_map" {
- description = "something"
- value = module.get_params.result_map
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement