Skip to content

Instantly share code, notes, and snippets.

@tjheslin1
Created June 2, 2019 10:26
Show Gist options
  • Save tjheslin1/ab352bc2dffe1ef9b3cf098412d9405f to your computer and use it in GitHub Desktop.
Save tjheslin1/ab352bc2dffe1ef9b3cf098412d9405f to your computer and use it in GitHub Desktop.
resource "aws_iam_role" "lambda-exec-role" {
name = "lambda-exec-role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
resource "aws_lambda_function" "simulator_function" {
function_name = "simulator_function"
handler = "example.Main::handleRequest"
runtime = "java8"
timeout = 180
memory_size = "512"
role = "${aws_iam_role.lambda-exec-role.arn}"
s3_bucket = "${aws_s3_bucket.artifacts.id}"
s3_key = "full.jar"
}
resource "aws_lambda_permission" "simulator_function_permission" {
action = "lambda:InvokeFunction"
function_name = "${aws_lambda_function.simulator_function.function_name}"
principal = "apigateway.amazonaws.com"
statement_id = "AllowExecutionFromAPIGateway"
source_arn = "${aws_api_gateway_rest_api.simulator-gateway.execution_arn}/*/*/*"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment