Skip to content

Commit

Permalink
Don't attempt to validate EOL runtimes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Aug 17, 2020
1 parent f8058cf commit c11f488
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
3 changes: 2 additions & 1 deletion aws/data_source_aws_lambda_layer_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/lambda"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

func dataSourceAwsLambdaLayerVersion() *schema.Resource {
Expand All @@ -27,7 +28,7 @@ func dataSourceAwsLambdaLayerVersion() *schema.Resource {
"compatible_runtime": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validateLambdaRuntime,
ValidateFunc: validation.StringInSlice(lambda.Runtime_Values(), false),
ConflictsWith: []string{"version"},
},
"compatible_runtimes": {
Expand Down
8 changes: 1 addition & 7 deletions aws/resource_aws_lambda_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ import (

const awsMutexLambdaKey = `aws_lambda_function`

var validateLambdaRuntime = validation.All(
validation.StringInSlice(lambda.Runtime_Values(), false),
// lambda.RuntimeNodejs has reached end of life since October 2016 so not included here
validation.StringNotInSlice([]string{lambda.RuntimeNodejs}, false),
)

func resourceAwsLambdaFunction() *schema.Resource {
return &schema.Resource{
Create: resourceAwsLambdaFunctionCreate,
Expand Down Expand Up @@ -148,7 +142,7 @@ func resourceAwsLambdaFunction() *schema.Resource {
"runtime": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validateLambdaRuntime,
ValidateFunc: validation.StringInSlice(lambda.Runtime_Values(), false),
},
"timeout": {
Type: schema.TypeInt,
Expand Down
5 changes: 1 addition & 4 deletions aws/resource_aws_lambda_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1352,10 +1352,7 @@ func TestAccAWSLambdaFunction_runtimes(t *testing.T) {

steps := []resource.TestStep{
{
Config: testAccAWSLambdaConfigRuntime(rName, lambda.RuntimeNodejs),
ExpectError: regexp.MustCompile(`expected runtime to not be any of`),
},
{
// Test invalid runtime.
Config: testAccAWSLambdaConfigRuntime(rName, rName),
ExpectError: regexp.MustCompile(`expected runtime to be one of`),
},
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_lambda_layer_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func resourceAwsLambdaLayerVersion() *schema.Resource {
MaxItems: 5,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validateLambdaRuntime,
ValidateFunc: validation.StringInSlice(lambda.Runtime_Values(), false),
},
},
"description": {
Expand Down

0 comments on commit c11f488

Please sign in to comment.