Added Tagging
This commit is contained in:
parent
1cecb37ab9
commit
840e6f4826
|
@ -58,13 +58,13 @@ func resourceAwsVpc() *schema.Resource {
|
|||
Computed: true,
|
||||
},
|
||||
|
||||
// "tags": tagsSchema(),
|
||||
"tags": tagsSchema(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceAwsVpcCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).awsEc2conn
|
||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
||||
instance_tenancy := "default"
|
||||
if v, ok := d.GetOk("instance_tenancy"); ok {
|
||||
instance_tenancy = v.(string)
|
||||
|
@ -110,7 +110,7 @@ func resourceAwsVpcCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).awsEc2conn
|
||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
||||
|
||||
// Refresh the VPC state
|
||||
vpcRaw, _, err := VPCStateRefreshFunc(ec2conn, d.Id())()
|
||||
|
@ -127,8 +127,8 @@ func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
|
|||
vpcid := d.Id()
|
||||
d.Set("cidr_block", vpc.CIDRBlock)
|
||||
|
||||
// Tags - TBD rmenn
|
||||
//d.Set("tags", tagsToMap(vpc.Tags))
|
||||
// Tags
|
||||
d.Set("tags", tagsToMapSDK(vpc.Tags))
|
||||
|
||||
// Attributes
|
||||
attribute := "enableDnsSupport"
|
||||
|
@ -180,7 +180,7 @@ func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
|
||||
func resourceAwsVpcUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).awsEc2conn
|
||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
||||
|
||||
// Turn on partial mode
|
||||
d.Partial(true)
|
||||
|
@ -219,19 +219,19 @@ func resourceAwsVpcUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
d.SetPartial("enable_dns_support")
|
||||
}
|
||||
//Tagging Support need to be worked on - rmenn
|
||||
// if err := setTags(ec2conn, d); err != nil {
|
||||
// return err
|
||||
// } else {
|
||||
// d.SetPartial("tags")
|
||||
// }
|
||||
|
||||
if err := setTagsSDK(ec2conn, d); err != nil {
|
||||
return err
|
||||
} else {
|
||||
d.SetPartial("tags")
|
||||
}
|
||||
|
||||
d.Partial(false)
|
||||
return resourceAwsVpcRead(d, meta)
|
||||
}
|
||||
|
||||
func resourceAwsVpcDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
ec2conn := meta.(*AWSClient).awsEc2conn
|
||||
ec2conn := meta.(*AWSClient).awsEC2conn
|
||||
vpcID := d.Id()
|
||||
DeleteVpcOpts := &ec2.DeleteVPCRequest{
|
||||
VPCID: &vpcID,
|
||||
|
|
|
@ -50,36 +50,36 @@ func TestAccVpc_dedicatedTenancy(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
//func TestAccVpc_tags(t *testing.T) {
|
||||
// var vpc ec2.VPC
|
||||
//
|
||||
// resource.Test(t, resource.TestCase{
|
||||
// PreCheck: func() { testAccPreCheck(t) },
|
||||
// Providers: testAccProviders,
|
||||
// CheckDestroy: testAccCheckVpcDestroy,
|
||||
// Steps: []resource.TestStep{
|
||||
// resource.TestStep{
|
||||
// Config: testAccVpcConfigTags,
|
||||
// Check: resource.ComposeTestCheckFunc(
|
||||
// testAccCheckVpcExists("aws_vpc.foo", &vpc),
|
||||
// testAccCheckVpcCidr(&vpc, "10.1.0.0/16"),
|
||||
// resource.TestCheckResourceAttr(
|
||||
// "aws_vpc.foo", "cidr_block", "10.1.0.0/16"),
|
||||
// testAccCheckTags(&vpc.Tags, "foo", "bar"),
|
||||
// ),
|
||||
// },
|
||||
//
|
||||
// resource.TestStep{
|
||||
// Config: testAccVpcConfigTagsUpdate,
|
||||
// Check: resource.ComposeTestCheckFunc(
|
||||
// testAccCheckVpcExists("aws_vpc.foo", &vpc),
|
||||
// testAccCheckTags(&vpc.Tags, "foo", ""),
|
||||
// testAccCheckTags(&vpc.Tags, "bar", "baz"),
|
||||
// ),
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
//}
|
||||
func TestAccVpc_tags(t *testing.T) {
|
||||
var vpc ec2.VPC
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckVpcDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccVpcConfigTags,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckVpcExists("aws_vpc.foo", &vpc),
|
||||
testAccCheckVpcCidr(&vpc, "10.1.0.0/16"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_vpc.foo", "cidr_block", "10.1.0.0/16"),
|
||||
testAccCheckTagsSDK(&vpc.Tags, "foo", "bar"),
|
||||
),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
Config: testAccVpcConfigTagsUpdate,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckVpcExists("aws_vpc.foo", &vpc),
|
||||
testAccCheckTagsSDK(&vpc.Tags, "foo", ""),
|
||||
testAccCheckTagsSDK(&vpc.Tags, "bar", "baz"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccVpcUpdate(t *testing.T) {
|
||||
var vpc ec2.VPC
|
||||
|
@ -111,7 +111,7 @@ func TestAccVpcUpdate(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckVpcDestroy(s *terraform.State) error {
|
||||
conn := testAccProvider.Meta().(*AWSClient).awsEc2conn
|
||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "aws_vpc" {
|
||||
|
@ -166,7 +166,7 @@ func testAccCheckVpcExists(n string, vpc *ec2.VPC) resource.TestCheckFunc {
|
|||
return fmt.Errorf("No VPC ID is set")
|
||||
}
|
||||
|
||||
conn := testAccProvider.Meta().(*AWSClient).awsEc2conn
|
||||
conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
|
||||
DescribeVpcOpts := &ec2.DescribeVPCsRequest{
|
||||
VPCIDs: []string{rs.Primary.ID},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue