Merge pull request #10492 from Ninir/lambda_env_removal

provider/aws: Fixed Lambda environment removal
This commit is contained in:
Clint 2016-12-05 14:33:11 -06:00 committed by GitHub
commit f8f4634858
2 changed files with 26 additions and 0 deletions

View File

@ -495,6 +495,11 @@ func resourceAwsLambdaFunctionUpdate(d *schema.ResourceData, meta interface{}) e
}
configUpdate = true
}
} else {
configReq.Environment = &lambda.Environment{
Variables: aws.StringMap(map[string]string{}),
}
configUpdate = true
}
}

View File

@ -77,6 +77,16 @@ func TestAccAWSLambdaFunction_envVariables(t *testing.T) {
resource.TestCheckResourceAttr("aws_lambda_function.lambda_function_test", "environment.0.variables.foo1", "bar1"),
),
},
{
Config: testAccAWSLambdaConfigEnvVariablesModifiedWithoutEnvironment(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsLambdaFunctionExists("aws_lambda_function.lambda_function_test", rName, &conf),
testAccCheckAwsLambdaFunctionName(&conf, rName),
testAccCheckAwsLambdaFunctionArnHasSuffix(&conf, ":"+rName),
resource.TestCheckResourceAttr("aws_lambda_function.lambda_function_test", "environment.0.variables.foo", ""),
resource.TestCheckResourceAttr("aws_lambda_function.lambda_function_test", "environment.0.variables.foo1", ""),
),
},
},
})
}
@ -648,6 +658,17 @@ resource "aws_lambda_function" "lambda_function_test" {
`, rName)
}
func testAccAWSLambdaConfigEnvVariablesModifiedWithoutEnvironment(rName string) string {
return fmt.Sprintf(baseAccAWSLambdaConfig+`
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"
}
`, rName)
}
func testAccAWSLambdaConfigEncryptedEnvVariables(rName string) string {
return fmt.Sprintf(baseAccAWSLambdaConfig+`
resource "aws_kms_key" "foo" {