Skip to content

Commit a38cd68

Browse files
committed
fixed advanced example and upgraded lambda to node 14
1 parent 567a524 commit a38cd68

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

examples/advanced/advanced-example.tf

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@ provider "aws" {
33
region = "us-west-2"
44
}
55

6+
variable "postman_api_key" {
7+
type = string
8+
}
9+
610
data aws_ssm_parameter role_permissions_boundary_arn {
711
name = "/acs/iam/iamRolePermissionBoundary"
812
}
9-
10-
variable "postman_api_key" {
11-
type = string
13+
data "aws_ssm_parameter" "vpc_name" {
14+
name = "/acs/vpc/vpc-name"
15+
}
16+
data "aws_ssm_parameter" "vpc_id" {
17+
name = "/acs/vpc/${data.aws_ssm_parameter.vpc_name.value}"
18+
}
19+
data "aws_ssm_parameter" "subnet_id" {
20+
name = "/acs/vpc/${data.aws_ssm_parameter.vpc_name.value}-private-a"
1221
}
1322

1423
module "postman_test_lambda" {
@@ -26,4 +35,8 @@ module "postman_test_lambda" {
2635
]
2736
postman_api_key = var.postman_api_key
2837
role_permissions_boundary_arn = data.aws_ssm_parameter.role_permissions_boundary_arn.value
38+
vpc_id = data.aws_ssm_parameter.vpc_id.value
39+
vpc_subnet_ids = [data.aws_ssm_parameter.subnet_id.value]
40+
memory_size = 528
41+
timeout = 120
2942
}

lambda/dist/function.zip

6 Bytes
Binary file not shown.

lambda/src/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ exports.handler = async function (event, context) {
2323
error = new Error('Env variable POSTMAN_COLLECTIONS is required')
2424
} else {
2525
const postmanList = JSON.parse(postmanCollections)
26-
const promises = []
26+
const promises = [timer]
2727
for (const each of postmanList) {
2828
if (each.collection.includes('.json')) {
2929
promises.push(downloadFileFromBucket(each.collection))
@@ -42,10 +42,9 @@ exports.handler = async function (event, context) {
4242
}
4343
}
4444
}
45+
// finish the 10 second timer before trying to run the postman tests as well as finish downloading any files
4546
await Promise.all(promises)
4647

47-
// finish the 10 second timer before trying to run the postman tests
48-
await timer
4948
if (!error) {
5049
// no need to run tests if files weren't downloaded correctly
5150
for (const each of postmanList) {

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ resource "aws_lambda_function" "test_lambda" {
176176
function_name = local.lambda_function_name
177177
role = aws_iam_role.test_lambda.arn
178178
handler = "index.handler"
179-
runtime = "nodejs12.x"
179+
runtime = "nodejs14.x"
180180
timeout = var.timeout
181181
memory_size = var.memory_size
182182
source_code_hash = base64sha256("${path.module}/lambda/dist/function.zip")

0 commit comments

Comments
 (0)