diff --git a/infrastructure/lambda/prod-panaetius-blog-lambda/main.js b/infrastructure/lambda/prod-panaetius-blog-lambda/main.js index 8ddc9f2..6c9f2bf 100644 --- a/infrastructure/lambda/prod-panaetius-blog-lambda/main.js +++ b/infrastructure/lambda/prod-panaetius-blog-lambda/main.js @@ -5,10 +5,17 @@ exports.handler = (event, context, callback) => { var request = event.Records[0].cf.request; // Extract the URI from the request - var oldURI = request.url; + var oldURI = request.uri; // Match any '/' that occurs at the end of a URI. Replace it with a default index - var newURI = oldURI.replace(/\/$, '\/index.html'/); + function replace_uri(uri) { + uri = uri.replace(/\/$/, "/index.html"); + // uri = uri.replace(/\.io\/search\?q\=(.*)/, ".io/search/index.html?q=$1"); + // console.log(uri) + return uri; + } + // var newURI = oldURI.replace(/\/$/, "/index.html"); + var newURI = replace_uri(oldURI); // Log the URI as received by Cloudfront and the new URI to be used to fetch from the origin console.log(`Old URI: ${oldURI}`); @@ -18,5 +25,5 @@ exports.handler = (event, context, callback) => { request.uri = newURI; // Return to Cloudfront - return callback(null, request) + return callback(null, request); }; diff --git a/infrastructure/lambda/prod-panaetius-blog-lambda/main.js.zip b/infrastructure/lambda/prod-panaetius-blog-lambda/main.js.zip new file mode 100644 index 0000000..bfff512 Binary files /dev/null and b/infrastructure/lambda/prod-panaetius-blog-lambda/main.js.zip differ diff --git a/infrastructure/lambda/prod-panaetius-blog-lambda/main.zip b/infrastructure/lambda/prod-panaetius-blog-lambda/main.zip deleted file mode 100644 index 8913aa0..0000000 Binary files a/infrastructure/lambda/prod-panaetius-blog-lambda/main.zip and /dev/null differ diff --git a/infrastructure/main.tf b/infrastructure/main.tf index 76e1ac0..8ccdb20 100644 --- a/infrastructure/main.tf +++ b/infrastructure/main.tf @@ -35,16 +35,11 @@ module "cloudfront_s3_cdn" { tags = local.tags aliases = var.aliases index_document = "index.html" - - ordered_cache = [ + lambda_function_association = [ { - lambda_function_association = [ - { - event_type : "origin-request", - lambda_arn : aws_lambda_function.directory_indexes.qualified_arn, - include_body : false - } - ] + event_type : "origin-request", + lambda_arn : aws_lambda_function.directory_indexes.qualified_arn, + include_body : false } ] @@ -65,34 +60,42 @@ module "cloudfront_s3_cdn" { EOT } -# cloudfront lambda@edge +# # cloudfront lambda@edge -resource "aws_s3_bucket" "lambda_s3" { - provider = aws.us_east_1 - region = var.s3_region - bucket = "${var.stage}-${var.name}-lambda-function" - acl = var.acl - tags = local.tags +# resource "aws_s3_bucket" "lambda_s3" { +# provider = aws.us_east_1 +# region = var.s3_region +# bucket = "${var.stage}-${var.name}-lambda-function" +# acl = var.acl +# tags = local.tags +# } + +data "archive_file" "lambda_main" { + type = "zip" + source_file = var.source_file + output_path = "${var.source_file}.zip" } -resource "aws_s3_bucket_object" "main" { - provider = aws.us_east_1 - bucket = aws_s3_bucket.lambda_s3.id - key = var.lambda_key - acl = var.acl - source = var.source_file -} +# resource "aws_s3_bucket_object" "main" { +# provider = aws.us_east_1 +# bucket = aws_s3_bucket.lambda_s3.id +# key = var.lambda_key +# acl = var.acl +# source = var.source_file +# } resource "aws_lambda_function" "directory_indexes" { provider = aws.us_east_1 function_name = "${var.stage}-${var.name}-directory_indexes" - s3_bucket = aws_s3_bucket.lambda_s3.id - s3_key = var.lambda_key - handler = var.handler - runtime = var.runtime - role = aws_iam_role.lambda_role.arn - publish = true - tags = local.tags + filename = "${var.source_file}.zip" + source_code_hash = data.archive_file.lambda_main.output_base64sha256 + # s3_bucket = aws_s3_bucket.lambda_s3.id + # s3_key = var.lambda_key + handler = var.handler + runtime = var.runtime + role = aws_iam_role.lambda_role.arn + publish = true + tags = local.tags depends_on = [aws_iam_role_policy_attachment.lambda_logging] } diff --git a/infrastructure/terraform.tfstate.d/prod-eu-west-1/terraform.tfstate b/infrastructure/terraform.tfstate.d/prod-eu-west-1/terraform.tfstate index 4da18b0..4e242b5 100644 --- a/infrastructure/terraform.tfstate.d/prod-eu-west-1/terraform.tfstate +++ b/infrastructure/terraform.tfstate.d/prod-eu-west-1/terraform.tfstate @@ -1,7 +1,7 @@ { "version": 4, "terraform_version": "0.12.26", - "serial": 244, + "serial": 281, "lineage": "cda52006-90fc-4aec-a630-42e69057b365", "outputs": { "cf_arn": { @@ -13,7 +13,7 @@ "type": "string" }, "cf_etag": { - "value": "E3169NR3BVK3DJ", + "value": "E2UYU85RHS3J18", "type": "string" }, "cf_hosted_zone_id": { @@ -38,6 +38,32 @@ } }, "resources": [ + { + "mode": "data", + "type": "archive_file", + "name": "lambda_main", + "provider": "provider.archive", + "instances": [ + { + "schema_version": 0, + "attributes": { + "excludes": null, + "id": "320d4868dd37d1674e98bd790b8a54b006838d04", + "output_base64sha256": "5EVmwQDkgGfYMpMXNaWHUz3cmb/dSssoWl8mM8o3aMs=", + "output_md5": "611fc9e8b494e4b399217f632b8e35ed", + "output_path": "./lambda/prod-panaetius-blog-lambda/main.js.zip", + "output_sha": "320d4868dd37d1674e98bd790b8a54b006838d04", + "output_size": 601, + "source": [], + "source_content": null, + "source_content_filename": null, + "source_dir": null, + "source_file": "./lambda/prod-panaetius-blog-lambda/main.js", + "type": "zip" + } + } + ] + }, { "module": "module.cloudfront_s3_cdn", "mode": "data", @@ -307,7 +333,7 @@ { "event_type": "origin-request", "include_body": false, - "lambda_arn": "arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes:1" + "lambda_arn": "arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes:7" } ], "max_ttl": 31536000, @@ -321,13 +347,13 @@ "default_root_object": "index.html", "domain_name": "d244ranky0ff54.cloudfront.net", "enabled": true, - "etag": "E3169NR3BVK3DJ", + "etag": "E2UYU85RHS3J18", "hosted_zone_id": "Z2FDTNDATAQYW2", "http_version": "http2", "id": "E2IHXIMPI3MZ2X", "in_progress_validation_batches": 0, "is_ipv6_enabled": true, - "last_modified_time": "2020-07-19 01:54:58.16 +0000 UTC", + "last_modified_time": "2020-07-21 21:34:03.839 +0000 UTC", "logging_config": [ { "bucket": "prod-panaetius-blog-logs.s3.amazonaws.com", @@ -384,6 +410,8 @@ }, "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", "dependencies": [ + "aws_iam_role.lambda_role", + "aws_iam_role_policy_attachment.lambda_logging", "aws_lambda_function.directory_indexes", "module.cloudfront_s3_cdn.aws_cloudfront_origin_access_identity.default", "module.cloudfront_s3_cdn.aws_s3_bucket.origin", @@ -446,7 +474,7 @@ "attributes": { "arn": "arn:aws:iam::745437999005:role/prod-panaetius-blog-lambda", "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"Service\":[\"lambda.amazonaws.com\",\"edgelambda.amazonaws.com\"]},\"Action\":\"sts:AssumeRole\"}]}", - "create_date": "2020-07-19T01:43:08Z", + "create_date": "2020-07-21T20:01:43Z", "description": "", "force_detach_policies": false, "id": "prod-panaetius-blog-lambda", @@ -459,7 +487,7 @@ "Description": "terraform resources to host the blog", "Project": "panaetius-blog" }, - "unique_id": "AROA23D4RF6OUVG5PVTDO" + "unique_id": "AROA23D4RF6O2VEGAGEXM" }, "private": "bnVsbA==" } @@ -474,7 +502,7 @@ { "schema_version": 0, "attributes": { - "id": "prod-panaetius-blog-lambda-20200719014309715500000001", + "id": "prod-panaetius-blog-lambda-20200721200145100500000001", "policy_arn": "arn:aws:iam::745437999005:policy/prod-panaetius-blog-lambda_logging", "role": "prod-panaetius-blog-lambda" }, @@ -500,25 +528,25 @@ "description": "", "environment": [], "file_system_config": [], - "filename": null, + "filename": "./lambda/prod-panaetius-blog-lambda/main.js.zip", "function_name": "prod-panaetius-blog-directory_indexes", "handler": "main.handler", "id": "prod-panaetius-blog-directory_indexes", "invoke_arn": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes/invocations", "kms_key_arn": "", - "last_modified": "2020-07-19T01:48:58.316+0000", + "last_modified": "2020-07-21T21:34:00.971+0000", "layers": [], "memory_size": 128, "publish": true, - "qualified_arn": "arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes:1", + "qualified_arn": "arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes:7", "reserved_concurrent_executions": -1, "role": "arn:aws:iam::745437999005:role/prod-panaetius-blog-lambda", "runtime": "nodejs12.x", - "s3_bucket": "prod-panaetius-blog-lambda-function", - "s3_key": "main.zip", + "s3_bucket": null, + "s3_key": null, "s3_object_version": null, - "source_code_hash": "ltLABbdLTpAeXF5xOPf8vYj2Tq2wvINv206umQzPv0E=", - "source_code_size": 546, + "source_code_hash": "5EVmwQDkgGfYMpMXNaWHUz3cmb/dSssoWl8mM8o3aMs=", + "source_code_size": 601, "tags": { "Description": "terraform resources to host the blog", "Project": "panaetius-blog" @@ -530,14 +558,13 @@ "mode": "PassThrough" } ], - "version": "1", + "version": "7", "vpc_config": [] }, "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDB9fQ==", "dependencies": [ "aws_iam_role.lambda_role", - "aws_iam_role_policy_attachment.lambda_logging", - "aws_s3_bucket.lambda_s3" + "aws_iam_role_policy_attachment.lambda_logging" ] } ] @@ -736,53 +763,6 @@ } ] }, - { - "mode": "managed", - "type": "aws_s3_bucket", - "name": "lambda_s3", - "provider": "provider.aws.us_east_1", - "instances": [ - { - "schema_version": 0, - "attributes": { - "acceleration_status": "", - "acl": "private", - "arn": "arn:aws:s3:::prod-panaetius-blog-lambda-function", - "bucket": "prod-panaetius-blog-lambda-function", - "bucket_domain_name": "prod-panaetius-blog-lambda-function.s3.amazonaws.com", - "bucket_prefix": null, - "bucket_regional_domain_name": "prod-panaetius-blog-lambda-function.s3.amazonaws.com", - "cors_rule": [], - "force_destroy": false, - "grant": [], - "hosted_zone_id": "Z3AQBSTGFYJSTF", - "id": "prod-panaetius-blog-lambda-function", - "lifecycle_rule": [], - "logging": [], - "object_lock_configuration": [], - "policy": null, - "region": "us-east-1", - "replication_configuration": [], - "request_payer": "BucketOwner", - "server_side_encryption_configuration": [], - "tags": { - "Description": "terraform resources to host the blog", - "Project": "panaetius-blog" - }, - "versioning": [ - { - "enabled": false, - "mfa_delete": false - } - ], - "website": [], - "website_domain": null, - "website_endpoint": null - }, - "private": "bnVsbA==" - } - ] - }, { "module": "module.cloudfront_s3_cdn", "mode": "managed", @@ -856,47 +836,6 @@ } ] }, - { - "mode": "managed", - "type": "aws_s3_bucket_object", - "name": "main", - "provider": "provider.aws.us_east_1", - "instances": [ - { - "schema_version": 0, - "attributes": { - "acl": "private", - "bucket": "prod-panaetius-blog-lambda-function", - "cache_control": "", - "content": null, - "content_base64": null, - "content_disposition": "", - "content_encoding": "", - "content_language": "", - "content_type": "binary/octet-stream", - "etag": "e93809f5fe6e069bfa1fbee683a28d8c", - "force_destroy": false, - "id": "main.zip", - "key": "main.zip", - "kms_key_id": null, - "metadata": {}, - "object_lock_legal_hold_status": "", - "object_lock_mode": "", - "object_lock_retain_until_date": "", - "server_side_encryption": "", - "source": "./lambda/prod-panaetius-blog-lambda/main.zip", - "storage_class": "STANDARD", - "tags": {}, - "version_id": "", - "website_redirect": "" - }, - "private": "bnVsbA==", - "dependencies": [ - "aws_s3_bucket.lambda_s3" - ] - } - ] - }, { "module": "module.cloudfront_s3_cdn", "mode": "managed", diff --git a/infrastructure/terraform.tfstate.d/prod-eu-west-1/terraform.tfstate.backup b/infrastructure/terraform.tfstate.d/prod-eu-west-1/terraform.tfstate.backup index b5f0714..5453742 100644 --- a/infrastructure/terraform.tfstate.d/prod-eu-west-1/terraform.tfstate.backup +++ b/infrastructure/terraform.tfstate.d/prod-eu-west-1/terraform.tfstate.backup @@ -1,7 +1,7 @@ { "version": 4, "terraform_version": "0.12.26", - "serial": 242, + "serial": 278, "lineage": "cda52006-90fc-4aec-a630-42e69057b365", "outputs": { "cf_arn": { @@ -13,7 +13,7 @@ "type": "string" }, "cf_etag": { - "value": "E3169NR3BVK3DJ", + "value": "E1CTWNZ643PUQZ", "type": "string" }, "cf_hosted_zone_id": { @@ -38,6 +38,32 @@ } }, "resources": [ + { + "mode": "data", + "type": "archive_file", + "name": "lambda_main", + "provider": "provider.archive", + "instances": [ + { + "schema_version": 0, + "attributes": { + "excludes": null, + "id": "502af9bcd8bac1822a4052c962a3bd322746084b", + "output_base64sha256": "W5HchTpXhL2+aBI5O1Qzo25q4hxfbf+uhEln7zcrZpM=", + "output_md5": "e7f26d9ad3488ef6867a7f6bc2a7356a", + "output_path": "./lambda/prod-panaetius-blog-lambda/main.js.zip", + "output_sha": "502af9bcd8bac1822a4052c962a3bd322746084b", + "output_size": 597, + "source": [], + "source_content": null, + "source_content_filename": null, + "source_dir": null, + "source_file": "./lambda/prod-panaetius-blog-lambda/main.js", + "type": "zip" + } + } + ] + }, { "module": "module.cloudfront_s3_cdn", "mode": "data", @@ -307,7 +333,7 @@ { "event_type": "origin-request", "include_body": false, - "lambda_arn": "arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes:1" + "lambda_arn": "arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes:6" } ], "max_ttl": 31536000, @@ -321,13 +347,13 @@ "default_root_object": "index.html", "domain_name": "d244ranky0ff54.cloudfront.net", "enabled": true, - "etag": "E3169NR3BVK3DJ", + "etag": "E1CTWNZ643PUQZ", "hosted_zone_id": "Z2FDTNDATAQYW2", "http_version": "http2", "id": "E2IHXIMPI3MZ2X", "in_progress_validation_batches": 0, "is_ipv6_enabled": true, - "last_modified_time": "2020-07-19 01:54:58.16 +0000 UTC", + "last_modified_time": "2020-07-21 21:18:38.945 +0000 UTC", "logging_config": [ { "bucket": "prod-panaetius-blog-logs.s3.amazonaws.com", @@ -384,6 +410,8 @@ }, "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", "dependencies": [ + "aws_iam_role.lambda_role", + "aws_iam_role_policy_attachment.lambda_logging", "aws_lambda_function.directory_indexes", "module.cloudfront_s3_cdn.aws_cloudfront_origin_access_identity.default", "module.cloudfront_s3_cdn.aws_s3_bucket.origin", @@ -445,8 +473,8 @@ "schema_version": 0, "attributes": { "arn": "arn:aws:iam::745437999005:role/prod-panaetius-blog-lambda", - "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"},{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"edgelambda.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]}", - "create_date": "2020-07-19T01:43:08Z", + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"Service\":[\"lambda.amazonaws.com\",\"edgelambda.amazonaws.com\"]},\"Action\":\"sts:AssumeRole\"}]}", + "create_date": "2020-07-21T20:01:43Z", "description": "", "force_detach_policies": false, "id": "prod-panaetius-blog-lambda", @@ -459,7 +487,7 @@ "Description": "terraform resources to host the blog", "Project": "panaetius-blog" }, - "unique_id": "AROA23D4RF6OUVG5PVTDO" + "unique_id": "AROA23D4RF6O2VEGAGEXM" }, "private": "bnVsbA==" } @@ -474,7 +502,7 @@ { "schema_version": 0, "attributes": { - "id": "prod-panaetius-blog-lambda-20200719014309715500000001", + "id": "prod-panaetius-blog-lambda-20200721200145100500000001", "policy_arn": "arn:aws:iam::745437999005:policy/prod-panaetius-blog-lambda_logging", "role": "prod-panaetius-blog-lambda" }, @@ -500,25 +528,25 @@ "description": "", "environment": [], "file_system_config": [], - "filename": null, + "filename": "./lambda/prod-panaetius-blog-lambda/main.js.zip", "function_name": "prod-panaetius-blog-directory_indexes", "handler": "main.handler", "id": "prod-panaetius-blog-directory_indexes", "invoke_arn": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes/invocations", "kms_key_arn": "", - "last_modified": "2020-07-19T01:48:58.316+0000", + "last_modified": "2020-07-21T21:18:36.437+0000", "layers": [], "memory_size": 128, "publish": true, - "qualified_arn": "arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes:1", + "qualified_arn": "arn:aws:lambda:us-east-1:745437999005:function:prod-panaetius-blog-directory_indexes:6", "reserved_concurrent_executions": -1, "role": "arn:aws:iam::745437999005:role/prod-panaetius-blog-lambda", "runtime": "nodejs12.x", - "s3_bucket": "prod-panaetius-blog-lambda-function", - "s3_key": "main.zip", + "s3_bucket": null, + "s3_key": null, "s3_object_version": null, - "source_code_hash": "ltLABbdLTpAeXF5xOPf8vYj2Tq2wvINv206umQzPv0E=", - "source_code_size": 546, + "source_code_hash": "W5HchTpXhL2+aBI5O1Qzo25q4hxfbf+uhEln7zcrZpM=", + "source_code_size": 597, "tags": { "Description": "terraform resources to host the blog", "Project": "panaetius-blog" @@ -530,14 +558,13 @@ "mode": "PassThrough" } ], - "version": "1", + "version": "6", "vpc_config": [] }, "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDB9fQ==", "dependencies": [ "aws_iam_role.lambda_role", - "aws_iam_role_policy_attachment.lambda_logging", - "aws_s3_bucket.lambda_s3" + "aws_iam_role_policy_attachment.lambda_logging" ] } ] @@ -736,53 +763,6 @@ } ] }, - { - "mode": "managed", - "type": "aws_s3_bucket", - "name": "lambda_s3", - "provider": "provider.aws.us_east_1", - "instances": [ - { - "schema_version": 0, - "attributes": { - "acceleration_status": "", - "acl": "private", - "arn": "arn:aws:s3:::prod-panaetius-blog-lambda-function", - "bucket": "prod-panaetius-blog-lambda-function", - "bucket_domain_name": "prod-panaetius-blog-lambda-function.s3.amazonaws.com", - "bucket_prefix": null, - "bucket_regional_domain_name": "prod-panaetius-blog-lambda-function.s3.amazonaws.com", - "cors_rule": [], - "force_destroy": false, - "grant": [], - "hosted_zone_id": "Z3AQBSTGFYJSTF", - "id": "prod-panaetius-blog-lambda-function", - "lifecycle_rule": [], - "logging": [], - "object_lock_configuration": [], - "policy": null, - "region": "us-east-1", - "replication_configuration": [], - "request_payer": "BucketOwner", - "server_side_encryption_configuration": [], - "tags": { - "Description": "terraform resources to host the blog", - "Project": "panaetius-blog" - }, - "versioning": [ - { - "enabled": false, - "mfa_delete": false - } - ], - "website": [], - "website_domain": null, - "website_endpoint": null - }, - "private": "bnVsbA==" - } - ] - }, { "module": "module.cloudfront_s3_cdn", "mode": "managed", @@ -856,47 +836,6 @@ } ] }, - { - "mode": "managed", - "type": "aws_s3_bucket_object", - "name": "main", - "provider": "provider.aws.us_east_1", - "instances": [ - { - "schema_version": 0, - "attributes": { - "acl": "private", - "bucket": "prod-panaetius-blog-lambda-function", - "cache_control": "", - "content": null, - "content_base64": null, - "content_disposition": "", - "content_encoding": "", - "content_language": "", - "content_type": "binary/octet-stream", - "etag": "e93809f5fe6e069bfa1fbee683a28d8c", - "force_destroy": false, - "id": "main.zip", - "key": "main.zip", - "kms_key_id": null, - "metadata": {}, - "object_lock_legal_hold_status": "", - "object_lock_mode": "", - "object_lock_retain_until_date": "", - "server_side_encryption": "", - "source": "./lambda/prod-panaetius-blog-lambda/main.zip", - "storage_class": "STANDARD", - "tags": {}, - "version_id": "", - "website_redirect": "" - }, - "private": "bnVsbA==", - "dependencies": [ - "aws_s3_bucket.lambda_s3" - ] - } - ] - }, { "module": "module.cloudfront_s3_cdn", "mode": "managed", diff --git a/infrastructure/variables/prod-eu-west-1.tfvars b/infrastructure/variables/prod-eu-west-1.tfvars index f2da85f..a330cef 100644 --- a/infrastructure/variables/prod-eu-west-1.tfvars +++ b/infrastructure/variables/prod-eu-west-1.tfvars @@ -13,7 +13,7 @@ allowed_origins = ["*.panaetius.io"] # s3 & lambda acl = "private" lambda_key = "main.zip" -source_file = "./lambda/prod-panaetius-blog-lambda/main.zip" +source_file = "./lambda/prod-panaetius-blog-lambda/main.js" handler = "main.handler" runtime = "nodejs12.x" s3_region = "us-east-1"