Skip to content

Commit

Permalink
Merge pull request #6 from iambrianfallon/iambrianfallon-subnet-tags
Browse files Browse the repository at this point in the history
fixing broken tests for new tagging mechanism for VPC, subnet, and ro…
  • Loading branch information
Joe Stump authored May 14, 2020
2 parents 8343f86 + 0a60466 commit c464407
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 9 deletions.
6 changes: 3 additions & 3 deletions aws/resource_aws_route_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ func resourceAwsRouteTableRead(d *schema.ResourceData, meta interface{}) error {
// Tags
_, tagsAreDefined := d.GetOk("tags")
if tagsAreDefined {
if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(rt.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}
if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(rt.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}
}

d.Set("owner_id", rt.OwnerId)
Expand Down
5 changes: 5 additions & 0 deletions aws/resource_aws_route_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ func TestAccAWSRouteTable_tags(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
// This is needed because we don't always call d.Set() in Read for tags as per
// https://github.com/hashicorp/terraform/pull/21019 and https://github.com/hashicorp/terraform/issues/20985
"tags",
},
},
{
Config: testAccRouteTableConfigTagsUpdate,
Expand Down
6 changes: 3 additions & 3 deletions aws/resource_aws_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ func resourceAwsSubnetRead(d *schema.ResourceData, meta interface{}) error {

_, tagsAreDefined := d.GetOk("tags")
if tagsAreDefined {
if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(subnet.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}
if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(subnet.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}
}

d.Set("owner_id", subnet.OwnerId)
Expand Down
25 changes: 25 additions & 0 deletions aws/resource_aws_subnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ func TestAccAWSSubnet_basic(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
// This is needed because we don't always call d.Set() in Read for tags as per
// https://github.com/hashicorp/terraform/pull/21019 and https://github.com/hashicorp/terraform/issues/20985
"tags",
},
},
},
})
Expand Down Expand Up @@ -228,6 +233,11 @@ func TestAccAWSSubnet_ipv6(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
// This is needed because we don't always call d.Set() in Read for tags as per
// https://github.com/hashicorp/terraform/pull/21019 and https://github.com/hashicorp/terraform/issues/20985
"tags",
},
},
{
Config: testAccSubnetConfigIpv6UpdateAssignIpv6OnCreation,
Expand Down Expand Up @@ -271,6 +281,11 @@ func TestAccAWSSubnet_enableIpv6(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
// This is needed because we don't always call d.Set() in Read for tags as per
// https://github.com/hashicorp/terraform/pull/21019 and https://github.com/hashicorp/terraform/issues/20985
"tags",
},
},
{
Config: testAccSubnetConfigIpv6,
Expand Down Expand Up @@ -308,6 +323,11 @@ func TestAccAWSSubnet_availabilityZoneId(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
// This is needed because we don't always call d.Set() in Read for tags as per
// https://github.com/hashicorp/terraform/pull/21019 and https://github.com/hashicorp/terraform/issues/20985
"tags",
},
},
},
})
Expand Down Expand Up @@ -344,6 +364,11 @@ func TestAccAWSSubnet_outpost(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
// This is needed because we don't always call d.Set() in Read for tags as per
// https://github.com/hashicorp/terraform/pull/21019 and https://github.com/hashicorp/terraform/issues/20985
"tags",
},
},
},
})
Expand Down
6 changes: 3 additions & 3 deletions aws/resource_aws_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {

_, tagsAreDefined := d.GetOk("tags")
if tagsAreDefined {
if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(vpc.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}
if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(vpc.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}
}

d.Set("owner_id", vpc.OwnerId)
Expand Down
40 changes: 40 additions & 0 deletions aws/resource_aws_vpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ func TestAccAWSVpc_basic(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
// This is needed because we don't always call d.Set() in Read for tags as per
// https://github.com/hashicorp/terraform/pull/21019 and https://github.com/hashicorp/terraform/issues/20985
"tags",
},
},
},
})
Expand Down Expand Up @@ -211,6 +216,11 @@ func TestAccAWSVpc_AssignGeneratedIpv6CidrBlock(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
// This is needed because we don't always call d.Set() in Read for tags as per
// https://github.com/hashicorp/terraform/pull/21019 and https://github.com/hashicorp/terraform/issues/20985
"tags",
},
},
{
Config: testAccVpcConfigAssignGeneratedIpv6CidrBlock(false),
Expand Down Expand Up @@ -259,6 +269,11 @@ func TestAccAWSVpc_Tenancy(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
// This is needed because we don't always call d.Set() in Read for tags as per
// https://github.com/hashicorp/terraform/pull/21019 and https://github.com/hashicorp/terraform/issues/20985
"tags",
},
},
{
Config: testAccVpcConfig,
Expand Down Expand Up @@ -304,6 +319,11 @@ func TestAccAWSVpc_tags(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
// This is needed because we don't always call d.Set() in Read for tags as per
// https://github.com/hashicorp/terraform/pull/21019 and https://github.com/hashicorp/terraform/issues/20985
"tags",
},
},
{
Config: testAccVpcConfigTagsUpdate,
Expand Down Expand Up @@ -483,6 +503,11 @@ func TestAccAWSVpc_bothDnsOptionsSet(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
// This is needed because we don't always call d.Set() in Read for tags as per
// https://github.com/hashicorp/terraform/pull/21019 and https://github.com/hashicorp/terraform/issues/20985
"tags",
},
},
},
})
Expand All @@ -509,6 +534,11 @@ func TestAccAWSVpc_DisabledDnsSupport(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
// This is needed because we don't always call d.Set() in Read for tags as per
// https://github.com/hashicorp/terraform/pull/21019 and https://github.com/hashicorp/terraform/issues/20985
"tags",
},
},
},
})
Expand All @@ -534,6 +564,11 @@ func TestAccAWSVpc_classiclinkOptionSet(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
// This is needed because we don't always call d.Set() in Read for tags as per
// https://github.com/hashicorp/terraform/pull/21019 and https://github.com/hashicorp/terraform/issues/20985
"tags",
},
},
},
})
Expand All @@ -559,6 +594,11 @@ func TestAccAWSVpc_classiclinkDnsSupportOptionSet(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
// This is needed because we don't always call d.Set() in Read for tags as per
// https://github.com/hashicorp/terraform/pull/21019 and https://github.com/hashicorp/terraform/issues/20985
"tags",
},
},
},
})
Expand Down

0 comments on commit c464407

Please sign in to comment.