github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/builtin/providers/aws/import_aws_lambda_function_test.go (about)

     1  package aws
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/hashicorp/terraform/helper/acctest"
     8  	"github.com/hashicorp/terraform/helper/resource"
     9  )
    10  
    11  func TestAccAWSLambdaFunction_importLocalFile(t *testing.T) {
    12  	resourceName := "aws_lambda_function.lambda_function_test"
    13  
    14  	rSt := acctest.RandString(5)
    15  	rName := fmt.Sprintf("tf_test_%s", rSt)
    16  
    17  	resource.Test(t, resource.TestCase{
    18  		PreCheck:     func() { testAccPreCheck(t) },
    19  		Providers:    testAccProviders,
    20  		CheckDestroy: testAccCheckLambdaFunctionDestroy,
    21  		Steps: []resource.TestStep{
    22  			resource.TestStep{
    23  				Config: testAccAWSLambdaConfigBasic(rName, rSt),
    24  			},
    25  
    26  			resource.TestStep{
    27  				ResourceName:            resourceName,
    28  				ImportState:             true,
    29  				ImportStateVerify:       true,
    30  				ImportStateVerifyIgnore: []string{"filename", "publish"},
    31  			},
    32  		},
    33  	})
    34  }
    35  
    36  func TestAccAWSLambdaFunction_importLocalFile_VPC(t *testing.T) {
    37  	resourceName := "aws_lambda_function.lambda_function_test"
    38  
    39  	rSt := acctest.RandString(5)
    40  	rName := fmt.Sprintf("tf_test_%s", rSt)
    41  
    42  	resource.Test(t, resource.TestCase{
    43  		PreCheck:     func() { testAccPreCheck(t) },
    44  		Providers:    testAccProviders,
    45  		CheckDestroy: testAccCheckLambdaFunctionDestroy,
    46  		Steps: []resource.TestStep{
    47  			resource.TestStep{
    48  				Config: testAccAWSLambdaConfigWithVPC(rName, rSt),
    49  			},
    50  
    51  			resource.TestStep{
    52  				ResourceName:            resourceName,
    53  				ImportState:             true,
    54  				ImportStateVerify:       true,
    55  				ImportStateVerifyIgnore: []string{"filename", "publish"},
    56  			},
    57  		},
    58  	})
    59  }
    60  
    61  func TestAccAWSLambdaFunction_importS3(t *testing.T) {
    62  	resourceName := "aws_lambda_function.lambda_function_s3test"
    63  
    64  	rSt := acctest.RandString(5)
    65  	rName := fmt.Sprintf("tf_test_%s", rSt)
    66  
    67  	resource.Test(t, resource.TestCase{
    68  		PreCheck:     func() { testAccPreCheck(t) },
    69  		Providers:    testAccProviders,
    70  		CheckDestroy: testAccCheckLambdaFunctionDestroy,
    71  		Steps: []resource.TestStep{
    72  			resource.TestStep{
    73  				Config: testAccAWSLambdaConfigS3(rName, rSt),
    74  			},
    75  
    76  			resource.TestStep{
    77  				ResourceName:            resourceName,
    78  				ImportState:             true,
    79  				ImportStateVerify:       true,
    80  				ImportStateVerifyIgnore: []string{"s3_bucket", "s3_key", "publish"},
    81  			},
    82  		},
    83  	})
    84  }