Added Tagging

This commit is contained in:
Rahul Menon 2015-03-04 18:37:30 +05:30
parent 1cecb37ab9
commit 840e6f4826
2 changed files with 45 additions and 45 deletions

View File

@ -58,13 +58,13 @@ func resourceAwsVpc() *schema.Resource {
Computed: true, Computed: true,
}, },
// "tags": tagsSchema(), "tags": tagsSchema(),
}, },
} }
} }
func resourceAwsVpcCreate(d *schema.ResourceData, meta interface{}) error { func resourceAwsVpcCreate(d *schema.ResourceData, meta interface{}) error {
ec2conn := meta.(*AWSClient).awsEc2conn ec2conn := meta.(*AWSClient).awsEC2conn
instance_tenancy := "default" instance_tenancy := "default"
if v, ok := d.GetOk("instance_tenancy"); ok { if v, ok := d.GetOk("instance_tenancy"); ok {
instance_tenancy = v.(string) instance_tenancy = v.(string)
@ -110,7 +110,7 @@ func resourceAwsVpcCreate(d *schema.ResourceData, meta interface{}) error {
} }
func resourceAwsVpcRead(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 // Refresh the VPC state
vpcRaw, _, err := VPCStateRefreshFunc(ec2conn, d.Id())() vpcRaw, _, err := VPCStateRefreshFunc(ec2conn, d.Id())()
@ -127,8 +127,8 @@ func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
vpcid := d.Id() vpcid := d.Id()
d.Set("cidr_block", vpc.CIDRBlock) d.Set("cidr_block", vpc.CIDRBlock)
// Tags - TBD rmenn // Tags
//d.Set("tags", tagsToMap(vpc.Tags)) d.Set("tags", tagsToMapSDK(vpc.Tags))
// Attributes // Attributes
attribute := "enableDnsSupport" attribute := "enableDnsSupport"
@ -180,7 +180,7 @@ func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
} }
func resourceAwsVpcUpdate(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 // Turn on partial mode
d.Partial(true) d.Partial(true)
@ -219,19 +219,19 @@ func resourceAwsVpcUpdate(d *schema.ResourceData, meta interface{}) error {
d.SetPartial("enable_dns_support") d.SetPartial("enable_dns_support")
} }
//Tagging Support need to be worked on - rmenn
// if err := setTags(ec2conn, d); err != nil { if err := setTagsSDK(ec2conn, d); err != nil {
// return err return err
// } else { } else {
// d.SetPartial("tags") d.SetPartial("tags")
// } }
d.Partial(false) d.Partial(false)
return resourceAwsVpcRead(d, meta) return resourceAwsVpcRead(d, meta)
} }
func resourceAwsVpcDelete(d *schema.ResourceData, meta interface{}) error { func resourceAwsVpcDelete(d *schema.ResourceData, meta interface{}) error {
ec2conn := meta.(*AWSClient).awsEc2conn ec2conn := meta.(*AWSClient).awsEC2conn
vpcID := d.Id() vpcID := d.Id()
DeleteVpcOpts := &ec2.DeleteVPCRequest{ DeleteVpcOpts := &ec2.DeleteVPCRequest{
VPCID: &vpcID, VPCID: &vpcID,

View File

@ -50,36 +50,36 @@ func TestAccVpc_dedicatedTenancy(t *testing.T) {
}) })
} }
//func TestAccVpc_tags(t *testing.T) { func TestAccVpc_tags(t *testing.T) {
// var vpc ec2.VPC var vpc ec2.VPC
//
// resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
// PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
// Providers: testAccProviders, Providers: testAccProviders,
// CheckDestroy: testAccCheckVpcDestroy, CheckDestroy: testAccCheckVpcDestroy,
// Steps: []resource.TestStep{ Steps: []resource.TestStep{
// resource.TestStep{ resource.TestStep{
// Config: testAccVpcConfigTags, Config: testAccVpcConfigTags,
// Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
// testAccCheckVpcExists("aws_vpc.foo", &vpc), testAccCheckVpcExists("aws_vpc.foo", &vpc),
// testAccCheckVpcCidr(&vpc, "10.1.0.0/16"), testAccCheckVpcCidr(&vpc, "10.1.0.0/16"),
// resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
// "aws_vpc.foo", "cidr_block", "10.1.0.0/16"), "aws_vpc.foo", "cidr_block", "10.1.0.0/16"),
// testAccCheckTags(&vpc.Tags, "foo", "bar"), testAccCheckTagsSDK(&vpc.Tags, "foo", "bar"),
// ), ),
// }, },
//
// resource.TestStep{ resource.TestStep{
// Config: testAccVpcConfigTagsUpdate, Config: testAccVpcConfigTagsUpdate,
// Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
// testAccCheckVpcExists("aws_vpc.foo", &vpc), testAccCheckVpcExists("aws_vpc.foo", &vpc),
// testAccCheckTags(&vpc.Tags, "foo", ""), testAccCheckTagsSDK(&vpc.Tags, "foo", ""),
// testAccCheckTags(&vpc.Tags, "bar", "baz"), testAccCheckTagsSDK(&vpc.Tags, "bar", "baz"),
// ), ),
// }, },
// }, },
// }) })
//} }
func TestAccVpcUpdate(t *testing.T) { func TestAccVpcUpdate(t *testing.T) {
var vpc ec2.VPC var vpc ec2.VPC
@ -111,7 +111,7 @@ func TestAccVpcUpdate(t *testing.T) {
} }
func testAccCheckVpcDestroy(s *terraform.State) error { func testAccCheckVpcDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).awsEc2conn conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
for _, rs := range s.RootModule().Resources { for _, rs := range s.RootModule().Resources {
if rs.Type != "aws_vpc" { 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") return fmt.Errorf("No VPC ID is set")
} }
conn := testAccProvider.Meta().(*AWSClient).awsEc2conn conn := testAccProvider.Meta().(*AWSClient).awsEC2conn
DescribeVpcOpts := &ec2.DescribeVPCsRequest{ DescribeVpcOpts := &ec2.DescribeVPCsRequest{
VPCIDs: []string{rs.Primary.ID}, VPCIDs: []string{rs.Primary.ID},
} }