Commit 0c73bdff authored by Bertrand PINEL's avatar Bertrand PINEL

Update terraform script to include S3 lambda code bucket and to correct some strage behaviour...

parent 3d7522d3
This diff is collapsed.
......@@ -7,6 +7,17 @@ variable "bucket_name_staging" {
default = "ember-aws-ehipster-staging"
}
resource "aws_s3_bucket" "lambda-bucket" {
bucket = "lambda-jsonapi-code-bucket"
acl = "public-read"
}
resource "aws_s3_bucket_object" "lambda-bucket-code" {
bucket = "${aws_s3_bucket.lambda-bucket.bucket}"
key = "v1.0.0/lambda-jsonapi.zip"
source = "../lambda/lambda-jsonapi.zip"
etag = "${md5(file("../lambda/lambda-jsonapi.zip"))}"
}
resource "aws_s3_bucket" "production" {
bucket = "${var.bucket_name_production}"
acl = "public-read"
......
......@@ -10,8 +10,8 @@ resource "aws_lambda_function" "lambda-jsonapi" {
function_name = "lambda-jsonapi"
# The bucket name as created before running terraform scripts with "aws s3api create-bucket"
s3_bucket = "lambda-jsonapi-code-bucket"
s3_key = "v1.0.0/lambda-jsonapi.zip"
s3_bucket = "${aws_s3_bucket.lambda-bucket.bucket}"
s3_key = "${aws_s3_bucket_object.lambda-bucket-code.key}"
# "main" is the filename within the zip file (main.js) and "handler"
# is the name of the property under which the handler function was
......@@ -20,6 +20,8 @@ resource "aws_lambda_function" "lambda-jsonapi" {
runtime = "nodejs8.10"
role = "${aws_iam_role.lambda_jsonapi.arn}"
depends_on = ["aws_s3_bucket.lambda-bucket"]
}
......@@ -33,4 +35,6 @@ resource "aws_lambda_permission" "apigw" {
# The /*/* portion grants access from any method on any resource
# within the API Gateway "REST API".
source_arn = "${aws_api_gateway_deployment.jsonapiDeployment.execution_arn}/*/*"
depends_on = ["aws_iam_role.lambda_jsonapi"]
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment