Skip to content

Commit

Permalink
Merge pull request #35967 from surajsubramanian/b-lambda_replace-node…
Browse files Browse the repository at this point in the history
…js14

Replace use of `nodejs14.x` runtime for service/lambda acceptance tests
  • Loading branch information
ewbankkit authored Feb 26, 2024
2 parents bc74b10 + 322cc1c commit fa2db56
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 37 deletions.
8 changes: 4 additions & 4 deletions internal/service/lambda/function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,12 +683,12 @@ func TestAccLambdaFunction_versionedUpdate(t *testing.T) {
PreConfig: func() {
timeBeforeUpdate = time.Now()
},
Config: testAccFunctionConfig_versionedNodeJs14xRuntime(path, rName),
Config: testAccFunctionConfig_versionedNodeJs20xRuntime(path, rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckFunctionExists(ctx, resourceName, &conf),
resource.TestCheckResourceAttr(resourceName, "version", versionUpdated),
acctest.CheckResourceAttrRegionalARN(resourceName, "qualified_arn", "lambda", fmt.Sprintf("function:%s:%s", rName, versionUpdated)),
resource.TestCheckResourceAttr(resourceName, "runtime", string(types.RuntimeNodejs14x)),
resource.TestCheckResourceAttr(resourceName, "runtime", string(types.RuntimeNodejs20x)),
func(s *terraform.State) error {
return testAccCheckAttributeIsDateAfter(s, resourceName, "last_modified", timeBeforeUpdate)
},
Expand Down Expand Up @@ -3064,7 +3064,7 @@ resource "aws_lambda_function" "test" {
`, fileName, rName, publish))
}

func testAccFunctionConfig_versionedNodeJs14xRuntime(fileName, rName string) string {
func testAccFunctionConfig_versionedNodeJs20xRuntime(fileName, rName string) string {
return acctest.ConfigCompose(
acctest.ConfigLambdaBase(rName, rName, rName),
fmt.Sprintf(`
Expand All @@ -3074,7 +3074,7 @@ resource "aws_lambda_function" "test" {
publish = true
role = aws_iam_role.iam_for_lambda.arn
handler = "exports.example"
runtime = "nodejs14.x"
runtime = "nodejs20.x"
}
`, fileName, rName))
}
Expand Down
2 changes: 1 addition & 1 deletion internal/service/lambda/function_url_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ resource "aws_lambda_function" "test" {
function_name = %[1]q
handler = "exports.example"
role = aws_iam_role.lambda.arn
runtime = "nodejs14.x"
runtime = "nodejs20.x"
}
resource "aws_lambda_function_url" "test" {
Expand Down
12 changes: 6 additions & 6 deletions internal/service/lambda/function_url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ resource "aws_lambda_function" "test" {
function_name = %[1]q
role = aws_iam_role.iam_for_lambda.arn
handler = "exports.example"
runtime = "nodejs14.x"
runtime = "nodejs20.x"
}
resource "aws_lambda_function_url" "test" {
Expand All @@ -442,7 +442,7 @@ resource "aws_lambda_function" "test" {
function_name = %[1]q
role = aws_iam_role.iam_for_lambda.arn
handler = "exports.example"
runtime = "nodejs14.x"
runtime = "nodejs20.x"
}
resource "aws_lambda_function_url" "test" {
Expand All @@ -468,7 +468,7 @@ resource "aws_lambda_function" "test" {
function_name = %[1]q
role = aws_iam_role.iam_for_lambda.arn
handler = "exports.example"
runtime = "nodejs14.x"
runtime = "nodejs20.x"
}
resource "aws_lambda_function_url" "test" {
Expand All @@ -494,7 +494,7 @@ resource "aws_lambda_function" "test" {
function_name = %[1]q
role = aws_iam_role.iam_for_lambda.arn
handler = "exports.example"
runtime = "nodejs14.x"
runtime = "nodejs20.x"
publish = true
}
Expand Down Expand Up @@ -529,7 +529,7 @@ resource "aws_lambda_function" "test" {
function_name = %[1]q
role = aws_iam_role.iam_for_lambda.arn
handler = "exports.example"
runtime = "nodejs14.x"
runtime = "nodejs20.x"
}
resource "aws_lambda_function_url" "test" {
Expand All @@ -547,7 +547,7 @@ resource "aws_lambda_function" "test" {
function_name = %[1]q
role = aws_iam_role.iam_for_lambda.arn
handler = "exports.example"
runtime = "nodejs14.x"
runtime = "nodejs20.x"
publish = true
}
Expand Down
4 changes: 2 additions & 2 deletions internal/service/lambda/invocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func TestAccLambdaInvocation_lifecycle_scopeCreateOnlyToCRUD(t *testing.T) {
func TestAccLambdaInvocation_terraformKey(t *testing.T) {
ctx := acctest.Context(t)
resourceName := "aws_lambda_invocation.test"
fName := "lambda_invocation_crud"
fName := "lambda_invocation"
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

inputJSON := `{"key1":"value1","key2":"value2"}`
Expand Down Expand Up @@ -466,7 +466,7 @@ resource "aws_lambda_function" "test" {
function_name = %[2]q
role = aws_iam_role.test.arn
handler = "%[1]s.handler"
runtime = "nodejs14.x"
runtime = "nodejs18.x"
environment {
variables = {
Expand Down
6 changes: 3 additions & 3 deletions internal/service/lambda/layer_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func TestAccLambdaLayerVersion_skipDestroy(t *testing.T) {
CheckDestroy: acctest.CheckDestroyNoop, // this purposely leaves dangling resources, since skip_destroy = true
Steps: []resource.TestStep{
{
Config: testAccLayerVersionConfig_skipDestroy(rName, "nodejs14.x"),
Config: testAccLayerVersionConfig_skipDestroy(rName, "nodejs18.x"),
Check: resource.ComposeTestCheckFunc(
testAccCheckLayerVersionExists(ctx, resourceName),
acctest.CheckResourceAttrRegionalARN(resourceName, "arn", "lambda", fmt.Sprintf("layer:%s:1", rName)),
Expand All @@ -314,7 +314,7 @@ func TestAccLambdaLayerVersion_skipDestroy(t *testing.T) {
),
},
{
Config: testAccLayerVersionConfig_skipDestroy(rName, "nodejs16.x"),
Config: testAccLayerVersionConfig_skipDestroy(rName, "nodejs20.x"),
Check: resource.ComposeTestCheckFunc(
testAccCheckLayerVersionExists(ctx, resourceName),
acctest.CheckResourceAttrRegionalARN(resourceName, "arn", "lambda", fmt.Sprintf("layer:%s:2", rName)),
Expand Down Expand Up @@ -436,7 +436,7 @@ resource "aws_lambda_layer_version" "test" {
filename = "test-fixtures/lambdatest.zip"
layer_name = %[1]q
compatible_runtimes = ["nodejs14.x", "nodejs16.x"]
compatible_runtimes = ["nodejs18.x", "nodejs20.x"]
}
`, rName)
}
Expand Down
21 changes: 0 additions & 21 deletions internal/service/lambda/test-fixtures/lambda_invocation_crud.js

This file was deleted.

27 changes: 27 additions & 0 deletions internal/service/lambda/test-fixtures/lambda_invocation_crud.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

import { SSMClient, PutParameterCommand } from "@aws-sdk/client-ssm";

const ssmClient = new SSMClient();

export const handler = async (event) => {
let tf_key = "tf";
if (tf_key in event) {
if (event[tf_key].action == "delete" && process.env.TEST_DATA != "") {
try {
await ssmClient.send(new PutParameterCommand({
Name: process.env.TEST_DATA,
Value: JSON.stringify(event),
Type: "String"
}));
} catch (error) {
console.error("Error putting parameter:", error);
throw error;
}
}
}
return event;
}
Binary file modified internal/service/lambda/test-fixtures/lambda_invocation_crud.zip
Binary file not shown.

0 comments on commit fa2db56

Please sign in to comment.