2016-07-16 16:36:28 +02:00
|
|
|
package aws
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAccAWSLambdaFunction_importLocalFile(t *testing.T) {
|
|
|
|
resourceName := "aws_lambda_function.lambda_function_test"
|
|
|
|
|
2016-12-16 17:42:37 +01:00
|
|
|
rSt := acctest.RandString(5)
|
|
|
|
rName := fmt.Sprintf("tf_test_%s", rSt)
|
2016-07-16 16:36:28 +02:00
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckLambdaFunctionDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
resource.TestStep{
|
2016-12-16 17:42:37 +01:00
|
|
|
Config: testAccAWSLambdaConfigBasic(rName, rSt),
|
2016-07-16 16:36:28 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
resource.TestStep{
|
|
|
|
ResourceName: resourceName,
|
|
|
|
ImportState: true,
|
|
|
|
ImportStateVerify: true,
|
2016-09-04 10:55:13 +02:00
|
|
|
ImportStateVerifyIgnore: []string{"filename", "publish"},
|
2016-07-16 16:36:28 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAccAWSLambdaFunction_importLocalFile_VPC(t *testing.T) {
|
|
|
|
resourceName := "aws_lambda_function.lambda_function_test"
|
|
|
|
|
2016-12-16 17:42:37 +01:00
|
|
|
rSt := acctest.RandString(5)
|
|
|
|
rName := fmt.Sprintf("tf_test_%s", rSt)
|
2016-07-16 16:36:28 +02:00
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckLambdaFunctionDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
resource.TestStep{
|
2016-12-16 17:42:37 +01:00
|
|
|
Config: testAccAWSLambdaConfigWithVPC(rName, rSt),
|
2016-07-16 16:36:28 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
resource.TestStep{
|
|
|
|
ResourceName: resourceName,
|
|
|
|
ImportState: true,
|
|
|
|
ImportStateVerify: true,
|
2016-09-04 10:55:13 +02:00
|
|
|
ImportStateVerifyIgnore: []string{"filename", "publish"},
|
2016-07-16 16:36:28 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAccAWSLambdaFunction_importS3(t *testing.T) {
|
|
|
|
resourceName := "aws_lambda_function.lambda_function_s3test"
|
|
|
|
|
2016-12-16 17:42:37 +01:00
|
|
|
rSt := acctest.RandString(5)
|
|
|
|
rName := fmt.Sprintf("tf_test_%s", rSt)
|
2016-07-16 16:36:28 +02:00
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckLambdaFunctionDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
resource.TestStep{
|
2016-12-16 17:42:37 +01:00
|
|
|
Config: testAccAWSLambdaConfigS3(rName, rSt),
|
2016-07-16 16:36:28 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
resource.TestStep{
|
|
|
|
ResourceName: resourceName,
|
|
|
|
ImportState: true,
|
|
|
|
ImportStateVerify: true,
|
2016-09-04 10:55:13 +02:00
|
|
|
ImportStateVerifyIgnore: []string{"s3_bucket", "s3_key", "publish"},
|
2016-07-16 16:36:28 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|