Skip to content

Instantly share code, notes, and snippets.

@quatrix
Created January 20, 2022 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quatrix/9b0436e609bfbf7154fd7889786fedbf to your computer and use it in GitHub Desktop.
Save quatrix/9b0436e609bfbf7154fd7889786fedbf to your computer and use it in GitHub Desktop.
data "archive_file" "dead_man_switch" {
type = "zip"
output_path = "${path.module}/files/dead_man_switch.zip"
source_file = "lambdas/dead_man_switch.js"
}
data "archive_file" "authorizer" {
type = "zip"
output_path = "${path.module}/files/authorizer.zip"
source_file = "lambdas/authorizer.js"
}
resource "aws_lambda_function" "dead_man_switch" {
function_name = "dead_man_switch"
filename = data.archive_file.dead_man_switch.output_path
role = aws_iam_role.role.arn
handler = "dead_man_switch.handler"
source_code_hash = filebase64sha256(data.archive_file.dead_man_switch.output_path)
runtime = "nodejs12.x"
}
resource "aws_lambda_function" "authorizer" {
function_name = "authorizer"
filename = data.archive_file.authorizer.output_path
role = aws_iam_role.role.arn
handler = "authorizer.handler"
source_code_hash = filebase64sha256(data.archive_file.authorizer.output_path)
runtime = "nodejs12.x"
}
resource "aws_lambda_permission" "allow_dead_man_switch" {
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.dead_man_switch.function_name
principal = "apigateway.amazonaws.com"
}
resource "aws_lambda_permission" "allow_authorizer" {
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.authorizer.function_name
principal = "apigateway.amazonaws.com"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment