Skip to content

Instantly share code, notes, and snippets.

@rogerwelin
Created March 18, 2019 21:15
Show Gist options
  • Select an option

  • Save rogerwelin/2d020d822f803039e055324b706c2006 to your computer and use it in GitHub Desktop.

Select an option

Save rogerwelin/2d020d822f803039e055324b706c2006 to your computer and use it in GitHub Desktop.
############################################
# LAMBDA - Create the lambda function
############################################
resource "aws_lambda_function" "weather_api" {
function_name = "weather-api"
# fetch the artifact from bucket created earlier
s3_bucket = "${var.artifact_bucket}"
s3_key = "${var.artifact_zip_name}"
handler = "${var.faas_name}"
runtime = "go1.x"
role = "${aws_iam_role.lambda_role.arn}"
}
resource "aws_lambda_permission" "apigw" {
statement_id = "AllowAPIGatewayInvoke"
action = "lambda:InvokeFunction"
function_name = "${aws_lambda_function.weather_api.arn}"
principal = "apigateway.amazonaws.com"
source_arn = "${aws_api_gateway_rest_api.weather_gw.execution_arn}/*/*"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment