github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/aws/import_aws_elastic_beanstalk_environment_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 TestAWSElasticBeanstalkEnvironment_importBasic(t *testing.T) {
    12  	resourceName := "aws_elastic_beanstalk_application.tftest"
    13  
    14  	applicationName := fmt.Sprintf("tf-test-name-%d", acctest.RandInt())
    15  	environmentName := fmt.Sprintf("tf-test-env-name-%d", acctest.RandInt())
    16  
    17  	resource.Test(t, resource.TestCase{
    18  		PreCheck:     func() { testAccPreCheck(t) },
    19  		Providers:    testAccProviders,
    20  		CheckDestroy: testAccCheckBeanstalkAppDestroy,
    21  		Steps: []resource.TestStep{
    22  			{
    23  				Config: testAccBeanstalkEnvImportConfig(applicationName, environmentName),
    24  			},
    25  
    26  			{
    27  				ResourceName:      resourceName,
    28  				ImportState:       true,
    29  				ImportStateVerify: true,
    30  			},
    31  		},
    32  	})
    33  }
    34  
    35  func testAccBeanstalkEnvImportConfig(appName, envName string) string {
    36  	return fmt.Sprintf(`resource "aws_elastic_beanstalk_application" "tftest" {
    37  	  name = "%s"
    38  	  description = "tf-test-desc"
    39  	}
    40  
    41  	resource "aws_elastic_beanstalk_environment" "tfenvtest" {
    42  	  name = "%s"
    43  	  application = "${aws_elastic_beanstalk_application.tftest.name}"
    44  	  solution_stack_name = "64bit Amazon Linux running Python"
    45  	}`, appName, envName)
    46  }