Skip to content

Commit

Permalink
feat: add nodejs12.x and python3.8 lambda support
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanrubio committed Nov 19, 2019
1 parent 6130e73 commit ac59f82
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 1 deletion.
2 changes: 2 additions & 0 deletions aws/resource_aws_lambda_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ var validLambdaRuntimes = []string{
lambda.RuntimeNodejs610,
lambda.RuntimeNodejs810,
lambda.RuntimeNodejs10X,
lambda.RuntimeNodejs12X,
lambda.RuntimeProvided,
lambda.RuntimePython27,
lambda.RuntimePython36,
lambda.RuntimePython37,
lambda.RuntimePython38,
lambda.RuntimeRuby25,
}

Expand Down
90 changes: 89 additions & 1 deletion aws/resource_aws_lambda_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,38 @@ func TestAccAWSLambdaFunction_runtimeValidation_NodeJs10x(t *testing.T) {
})
}

func TestAccAWSLambdaFunction_runtimeValidation_NodeJs12x(t *testing.T) {
var conf lambda.GetFunctionOutput

rString := acctest.RandString(8)
resourceName := "aws_lambda_function.test"
funcName := fmt.Sprintf("tf_acc_policy_lambda_func_runtime_valid_nodejs12x_%s", rString)
policyName := fmt.Sprintf("tf_acc_policy_lambda_func_runtime_valid_nodejs12x_%s", rString)
roleName := fmt.Sprintf("tf_acc_role_lambda_func_runtime_valid_nodejs12x_%s", rString)
sgName := fmt.Sprintf("tf_acc_sg_lambda_func_runtime_valid_nodejs12x_%s", rString)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckLambdaFunctionDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSLambdaConfigNodeJs12xRuntime(funcName, policyName, roleName, sgName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsLambdaFunctionExists(resourceName, funcName, &conf),
resource.TestCheckResourceAttr(resourceName, "runtime", lambda.RuntimeNodejs12X),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"filename", "publish"},
},
},
})
}

func TestAccAWSLambdaFunction_runtimeValidation_python27(t *testing.T) {
var conf lambda.GetFunctionOutput

Expand Down Expand Up @@ -1398,7 +1430,7 @@ func TestAccAWSLambdaFunction_runtimeValidation_java11(t *testing.T) {
Config: testAccAWSLambdaConfigJava11Runtime(funcName, policyName, roleName, sgName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsLambdaFunctionExists(resourceName, funcName, &conf),
resource.TestCheckResourceAttr(resourceName, "runtime", lambda.RuntimeJava8),
resource.TestCheckResourceAttr(resourceName, "runtime", lambda.RuntimeJava11),
),
},
{
Expand Down Expand Up @@ -1563,6 +1595,38 @@ func TestAccAWSLambdaFunction_runtimeValidation_python37(t *testing.T) {
})
}

func TestAccAWSLambdaFunction_runtimeValidation_python38(t *testing.T) {
var conf lambda.GetFunctionOutput

rString := acctest.RandString(8)
resourceName := "aws_lambda_function.test"
funcName := fmt.Sprintf("tf_acc_lambda_func_runtime_valid_p38_%s", rString)
policyName := fmt.Sprintf("tf_acc_policy_lambda_func_runtime_valid_p38_%s", rString)
roleName := fmt.Sprintf("tf_acc_role_lambda_func_runtime_valid_p38_%s", rString)
sgName := fmt.Sprintf("tf_acc_sg_lambda_func_runtime_valid_p38_%s", rString)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckLambdaFunctionDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSLambdaConfigPython38Runtime(funcName, policyName, roleName, sgName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsLambdaFunctionExists(resourceName, funcName, &conf),
resource.TestCheckResourceAttr(resourceName, "runtime", lambda.RuntimePython38),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"filename", "publish"},
},
},
})
}

func TestAccAWSLambdaFunction_runtimeValidation_ruby25(t *testing.T) {
var conf lambda.GetFunctionOutput

Expand Down Expand Up @@ -2498,6 +2562,18 @@ resource "aws_lambda_function" "test" {
`, funcName)
}

func testAccAWSLambdaConfigNodeJs12xRuntime(funcName, policyName, roleName, sgName string) string {
return fmt.Sprintf(baseAccAWSLambdaConfig(policyName, roleName, sgName)+`
resource "aws_lambda_function" "test" {
filename = "test-fixtures/lambdatest.zip"
function_name = "%s"
role = "${aws_iam_role.iam_for_lambda.arn}"
handler = "exports.example"
runtime = "nodejs12.x"
}
`, funcName)
}

func testAccAWSLambdaConfigPython27Runtime(funcName, policyName, roleName, sgName string) string {
return fmt.Sprintf(baseAccAWSLambdaConfig(policyName, roleName, sgName)+`
resource "aws_lambda_function" "test" {
Expand Down Expand Up @@ -2603,6 +2679,18 @@ resource "aws_lambda_function" "test" {
`, funcName)
}

func testAccAWSLambdaConfigPython38Runtime(funcName, policyName, roleName, sgName string) string {
return fmt.Sprintf(baseAccAWSLambdaConfig(policyName, roleName, sgName)+`
resource "aws_lambda_function" "test" {
filename = "test-fixtures/lambdatest.zip"
function_name = "%s"
role = "${aws_iam_role.iam_for_lambda.arn}"
handler = "exports.example"
runtime = "python3.8"
}
`, funcName)
}

func testAccAWSLambdaConfigRuby25Runtime(funcName, policyName, roleName, sgName string) string {
return fmt.Sprintf(baseAccAWSLambdaConfig(policyName, roleName, sgName)+`
resource "aws_lambda_function" "test" {
Expand Down

0 comments on commit ac59f82

Please sign in to comment.