github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/aws/data_source_aws_vpc_endpoint_service_test.go (about) 1 package aws 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/hashicorp/terraform/helper/resource" 8 "github.com/hashicorp/terraform/terraform" 9 ) 10 11 func TestAccDataSourceAwsVpcEndpointService(t *testing.T) { 12 resource.Test(t, resource.TestCase{ 13 PreCheck: func() { testAccPreCheck(t) }, 14 Providers: testAccProviders, 15 Steps: []resource.TestStep{ 16 resource.TestStep{ 17 Config: testAccDataSourceAwsVpcEndpointServiceConfig, 18 Check: resource.ComposeTestCheckFunc( 19 testAccDataSourceAwsVpcEndpointServiceCheck("data.aws_vpc_endpoint_service.s3"), 20 ), 21 }, 22 }, 23 }) 24 } 25 26 func testAccDataSourceAwsVpcEndpointServiceCheck(name string) resource.TestCheckFunc { 27 return func(s *terraform.State) error { 28 rs, ok := s.RootModule().Resources[name] 29 if !ok { 30 return fmt.Errorf("root module has no resource called %s", name) 31 } 32 33 attr := rs.Primary.Attributes 34 35 name := attr["service_name"] 36 if name != "com.amazonaws.us-west-2.s3" { 37 return fmt.Errorf("bad service name %s", name) 38 } 39 40 return nil 41 } 42 } 43 44 const testAccDataSourceAwsVpcEndpointServiceConfig = ` 45 provider "aws" { 46 region = "us-west-2" 47 } 48 49 data "aws_vpc_endpoint_service" "s3" { 50 service = "s3" 51 } 52 `