github.com/koding/terraform@v0.6.4-0.20170608090606-5d7e0339779d/builtin/providers/aws/resource_aws_default_subnet_test.go (about)

     1  // make testacc TEST=./builtin/providers/aws/ TESTARGS='-run=TestAccAWSDefaultVpc_'
     2  package aws
     3  
     4  import (
     5  	"testing"
     6  
     7  	"github.com/aws/aws-sdk-go/service/ec2"
     8  	"github.com/hashicorp/terraform/helper/resource"
     9  	"github.com/hashicorp/terraform/terraform"
    10  )
    11  
    12  func TestAccAWSDefaultSubnet_basic(t *testing.T) {
    13  	var v ec2.Subnet
    14  
    15  	resource.Test(t, resource.TestCase{
    16  		PreCheck:     func() { testAccPreCheck(t) },
    17  		Providers:    testAccProviders,
    18  		CheckDestroy: testAccCheckAWSDefaultSubnetDestroy,
    19  		Steps: []resource.TestStep{
    20  			{
    21  				Config: testAccAWSDefaultSubnetConfigBasic,
    22  				Check: resource.ComposeTestCheckFunc(
    23  					testAccCheckSubnetExists("aws_default_subnet.foo", &v),
    24  					resource.TestCheckResourceAttr(
    25  						"aws_default_subnet.foo", "availability_zone", "us-west-2a"),
    26  					resource.TestCheckResourceAttr(
    27  						"aws_default_subnet.foo", "map_public_ip_on_launch", "true"),
    28  					resource.TestCheckResourceAttr(
    29  						"aws_default_subnet.foo", "assign_ipv6_address_on_creation", "false"),
    30  					resource.TestCheckResourceAttr(
    31  						"aws_default_subnet.foo", "tags.%", "1"),
    32  					resource.TestCheckResourceAttr(
    33  						"aws_default_subnet.foo", "tags.Name", "Default subnet for us-west-2a"),
    34  				),
    35  			},
    36  		},
    37  	})
    38  }
    39  
    40  func testAccCheckAWSDefaultSubnetDestroy(s *terraform.State) error {
    41  	// We expect subnet to still exist
    42  	return nil
    43  }
    44  
    45  const testAccAWSDefaultSubnetConfigBasic = `
    46  provider "aws" {
    47      region = "us-west-2"
    48  }
    49  
    50  resource "aws_default_subnet" "foo" {
    51  	availability_zone = "us-west-2a"
    52  	tags {
    53  		Name = "Default subnet for us-west-2a"
    54  	}
    55  }
    56  `