Skip to content

Commit 9d374af

Browse files
author
Tyler Ray
committed
Updated Examples
1 parent 2243534 commit 9d374af

File tree

6 files changed

+90
-2
lines changed

6 files changed

+90
-2
lines changed

examples/no-codedeploy/example.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ module "lambda_api" {
1919
https_certificate_arn = module.acs.certificate.arn
2020
vpc_id = module.acs.vpc.id
2121
public_subnet_ids = module.acs.public_subnet_ids
22-
private_subnet_ids = module.acs.private_subnet_ids
2322
role_permissions_boundary_arn = module.acs.role_permissions_boundary.arn
2423
}
2524

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
provider "aws" {
2+
version = "~> 2.56"
3+
region = "us-west-2"
4+
}
5+
6+
module "acs" {
7+
source = "github.com/byu-oit/terraform-aws-acs-info?ref=v2.1.0"
8+
}
9+
10+
module "lambda_api" {
11+
# source = "../../"
12+
source = "github.com/byu-oit/terraform-aws-lambda-api?ref=v1.0.0"
13+
app_name = "my-lambda"
14+
env = "dev"
15+
lambda_zip_file = "./src/lambda.zip"
16+
handler = "index.handler"
17+
runtime = "nodejs12.x"
18+
hosted_zone = module.acs.route53_zone
19+
https_certificate_arn = module.acs.certificate.arn
20+
vpc_id = module.acs.vpc.id
21+
public_subnet_ids = module.acs.public_subnet_ids
22+
role_permissions_boundary_arn = module.acs.role_permissions_boundary.arn
23+
24+
lambda_vpc_config = {
25+
subnet_ids = module.acs.private_subnet_ids
26+
security_group_ids = []
27+
}
28+
}
29+
30+
output "url" {
31+
value = module.lambda_api.dns_record.fqdn
32+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
exports.handler = async function (event, context) {
2+
/*
3+
const event = {
4+
'requestContext': {
5+
'elb': {
6+
'targetGroupArn': 'arn:aws:elasticloadbalancing:region:123456789012:targetgroup/my-target-group/6d0ecf831eec9f09'
7+
}
8+
},
9+
'httpMethod': 'GET',
10+
'path': '/',
11+
'queryStringParameters': { some_query: 'blah' },
12+
'headers': {
13+
'accept': 'text/html,application/xhtml+xml',
14+
'accept-language': 'en-US,en;q=0.8',
15+
'content-type': 'text/plain',
16+
'cookie': 'cookies',
17+
'host': 'lambda-846800462-us-east-2.elb.amazonaws.com',
18+
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6)',
19+
'x-amzn-trace-id': 'Root=1-5bdb40ca-556d8b0c50dc66f0511bf520',
20+
'x-forwarded-for': '72.21.198.66',
21+
'x-forwarded-port': '443',
22+
'x-forwarded-proto': 'https'
23+
},
24+
'isBase64Encoded': false,
25+
'body': 'request_body' // This is a string - If you want an object, you'll need to parse it
26+
}
27+
*/
28+
29+
console.log(event)
30+
console.log(context)
31+
32+
return {
33+
'isBase64Encoded': false,
34+
'statusCode': 200,
35+
'statusDescription': '200 OK',
36+
'headers': {
37+
'Set-cookie': 'cookies',
38+
'Content-Type': 'application/json'
39+
},
40+
'body': '{"message":"Hello, World! ... Yo!"}' // This needs to be a string - If you want to return JSON, you'll need to stringify it
41+
}
42+
}

examples/simple-lambda-in-vpc/src/package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "handler",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\""
8+
},
9+
"author": "",
10+
"license": "Apache-2.0"
11+
}

examples/simple-lambda-with-deploy-test/example.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ module "lambda_api" {
2020
https_certificate_arn = module.acs.certificate.arn
2121
vpc_id = module.acs.vpc.id
2222
public_subnet_ids = module.acs.public_subnet_ids
23-
private_subnet_ids = module.acs.private_subnet_ids
2423
role_permissions_boundary_arn = module.acs.role_permissions_boundary.arn
2524
codedeploy_test_listener_port = 4443
2625
use_codedeploy = true

0 commit comments

Comments
 (0)