2016-07-03 17:42:12 +02:00
|
|
|
package aws
|
|
|
|
|
|
|
|
import (
|
2016-11-25 16:44:41 +01:00
|
|
|
"fmt"
|
2016-07-03 17:42:12 +02:00
|
|
|
"testing"
|
|
|
|
|
2016-11-25 16:44:41 +01:00
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
2016-07-03 17:42:12 +02:00
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAWSElasticBeanstalkEnvironment_importBasic(t *testing.T) {
|
|
|
|
resourceName := "aws_elastic_beanstalk_application.tftest"
|
|
|
|
|
2016-11-25 16:44:41 +01:00
|
|
|
applicationName := fmt.Sprintf("tf-test-name-%d", acctest.RandInt())
|
|
|
|
environmentName := fmt.Sprintf("tf-test-env-name-%d", acctest.RandInt())
|
|
|
|
|
2016-07-03 17:42:12 +02:00
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckBeanstalkAppDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
2016-11-25 16:44:41 +01:00
|
|
|
{
|
|
|
|
Config: testAccBeanstalkEnvImportConfig(applicationName, environmentName),
|
2016-07-03 17:42:12 +02:00
|
|
|
},
|
|
|
|
|
2016-11-25 16:44:41 +01:00
|
|
|
{
|
2016-07-03 17:42:12 +02:00
|
|
|
ResourceName: resourceName,
|
|
|
|
ImportState: true,
|
|
|
|
ImportStateVerify: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
2016-11-25 16:44:41 +01:00
|
|
|
|
|
|
|
func testAccBeanstalkEnvImportConfig(appName, envName string) string {
|
|
|
|
return fmt.Sprintf(`resource "aws_elastic_beanstalk_application" "tftest" {
|
|
|
|
name = "%s"
|
|
|
|
description = "tf-test-desc"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_elastic_beanstalk_environment" "tfenvtest" {
|
|
|
|
name = "%s"
|
|
|
|
application = "${aws_elastic_beanstalk_application.tftest.name}"
|
|
|
|
solution_stack_name = "64bit Amazon Linux running Python"
|
|
|
|
}`, appName, envName)
|
|
|
|
}
|