Skip to content

Commit

Permalink
Support tags filter only
Browse files Browse the repository at this point in the history
  • Loading branch information
David Chamard committed May 6, 2019
1 parent e52ee8d commit dde952e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 108 deletions.
9 changes: 1 addition & 8 deletions aws/data_source_aws_eips.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ func dataSourceAwsEips() *schema.Resource {
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"filter": ec2CustomFiltersSchema(),
"tags": tagsSchemaComputed(),
"tags": tagsSchemaComputed(),
},
}
}
Expand All @@ -45,12 +44,6 @@ func dataSourceAwsEipsRead(d *schema.ResourceData, meta interface{}) error {

req := &ec2.DescribeAddressesInput{}

req.Filters = []*ec2.Filter{}

req.Filters = append(req.Filters, buildEC2CustomFilterList(
d.Get("filter").(*schema.Set),
)...)

req.Filters = append(req.Filters, buildEC2TagFilterList(
tagsFromMap(d.Get("tags").(map[string]interface{})),
)...)
Expand Down
100 changes: 0 additions & 100 deletions aws/data_source_aws_eips_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,6 @@ import (
"testing"
)

func TestAccDataSourceAwsEips_Filter(t *testing.T) {
var conf ec2.Address

dataSourceName := "data.aws_eips.test"
rName := acctest.RandomWithPrefix("tf-acc-test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSEIPDestroy,
Steps: []resource.TestStep{
{
Config: testAccDataSourceAwsEipsConfigFilter(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSEIPExists("aws_eip.test", &conf),
testAccCheckAWSEIPExists("aws_eip.test2", &conf),
resource.TestCheckResourceAttr(dataSourceName, "ids.#", "2"),
resource.TestCheckResourceAttr(dataSourceName, "public_ips.#", "2"),
),
},
},
})
}

func TestAccDataSourceAwsEipsClassic_Filter(t *testing.T) {
var conf ec2.Address

dataSourceName := "data.aws_eips.test"
rName := acctest.RandomWithPrefix("tf-acc-test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSEIPDestroy,
Steps: []resource.TestStep{
{
Config: testAccDataSourceAwsEipsClassicConfigFilter(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSEIPExists("aws_eip.test", &conf),
testAccCheckAWSEIPExists("aws_eip.test2", &conf),
resource.TestCheckResourceAttr(dataSourceName, "ids.#", "2"),
resource.TestCheckResourceAttr(dataSourceName, "public_ips.#", "2"),
),
},
},
})
}

func TestAccDataSourceAwsEips_Tags(t *testing.T) {
var conf ec2.Address

Expand Down Expand Up @@ -107,32 +59,6 @@ func TestAccDataSourceAwsEipsClassic_Tags(t *testing.T) {
})
}

func testAccDataSourceAwsEipsConfigFilter(rName string) string {
return fmt.Sprintf(`
resource "aws_eip" "test" {
vpc = true
tags = {
Name = %q
}
}
resource "aws_eip" "test2" {
vpc = true
tags = {
Name = %q
}
}
data "aws_eips" "test" {
filter {
name = "tag:Name"
values = ["${aws_eip.test.tags.Name}"]
}
}
`, rName, rName)
}

func testAccDataSourceAwsEipsConfigTags(rName string) string {
return fmt.Sprintf(`
resource "aws_eip" "test" {
Expand All @@ -151,32 +77,6 @@ data "aws_eips" "test" {
`, rName)
}

func testAccDataSourceAwsEipsClassicConfigFilter(rName string) string {
return fmt.Sprintf(`
resource "aws_eip" "test" {
vpc = false
tags = {
Name = %q
}
}
resource "aws_eip" "test2" {
vpc = true
tags = {
Name = %q
}
}
data "aws_eips" "test" {
filter {
name = "tag:Name"
values = ["${aws_eip.test.tags.Name}"]
}
}
`, rName, rName)
}

func testAccDataSourceAwsEipsClassicConfigTags(rName string) string {
return fmt.Sprintf(`
resource "aws_eip" "test" {
Expand Down

0 comments on commit dde952e

Please sign in to comment.