Skip to content

Commit

Permalink
feat(lambda): add py3.7 runtime support
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzhou committed Nov 26, 2018
1 parent da0d8c1 commit a80ab70
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aws/resource_aws_lambda_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/aws/aws-sdk-go/aws/arn"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/lambda"
"github.com/mitchellh/go-homedir"
homedir "github.com/mitchellh/go-homedir"

"errors"

Expand Down Expand Up @@ -116,6 +116,7 @@ func resourceAwsLambdaFunction() *schema.Resource {
lambda.RuntimeNodejs810,
lambda.RuntimePython27,
lambda.RuntimePython36,
lambda.RuntimePython37,
}, false),
},
"timeout": {
Expand Down
37 changes: 37 additions & 0 deletions aws/resource_aws_lambda_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,31 @@ func TestAccAWSLambdaFunction_runtimeValidation_python36(t *testing.T) {
},
})
}
func TestAccAWSLambdaFunction_runtimeValidation_python37(t *testing.T) {
var conf lambda.GetFunctionOutput

rString := acctest.RandString(8)

funcName := fmt.Sprintf("tf_acc_lambda_func_runtime_valid_p37_%s", rString)
policyName := fmt.Sprintf("tf_acc_policy_lambda_func_runtime_valid_p37_%s", rString)
roleName := fmt.Sprintf("tf_acc_role_lambda_func_runtime_valid_p37_%s", rString)
sgName := fmt.Sprintf("tf_acc_sg_lambda_func_runtime_valid_p37_%s", rString)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckLambdaFunctionDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSLambdaConfigPython37Runtime(funcName, policyName, roleName, sgName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsLambdaFunctionExists("aws_lambda_function.lambda_function_test", funcName, &conf),
resource.TestCheckResourceAttr("aws_lambda_function.lambda_function_test", "runtime", lambda.RuntimePython37),
),
},
},
})
}

func testAccCheckLambdaFunctionDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).lambdaconn
Expand Down Expand Up @@ -2023,6 +2048,18 @@ resource "aws_lambda_function" "lambda_function_test" {
`, funcName)
}

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

func genAWSLambdaFunctionConfig_local(filePath, roleName, funcName string) string {
return fmt.Sprintf(`
resource "aws_iam_role" "iam_for_lambda" {
Expand Down

0 comments on commit a80ab70

Please sign in to comment.