Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding EIP Data Source support for Tags #3505

Merged
merged 7 commits into from
Nov 13, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Adding test for tags in data source
vpadronblanco committed Feb 23, 2018
commit c6e0fd6dfad3ce873d460b8750d94c65de6edac4
40 changes: 40 additions & 0 deletions aws/data_source_aws_eip_test.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
@@ -58,6 +59,22 @@ func testAccDataSourceAwsEipCheck(name string) resource.TestCheckFunc {
}
}

func TestAccDataSourceAwsEip_tags(t *testing.T) {
rInt := acctest.RandInt()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccDataSourceAwsEip_tags_config(rInt),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.aws_eip.test", "tags.%", "2"),
),
},
},
})
}

const testAccDataSourceAwsEipConfig = `
provider "aws" {
region = "us-west-2"
@@ -75,3 +92,26 @@ data "aws_eip" "by_public_ip" {
public_ip = "${aws_eip.test.public_ip}"
}
`

func testAccDataSourceAwsEip_tags_config(rInt int) string {
return fmt.Sprintf(
`
provider "aws" {
region = "us-west-2"
}
resource "aws_eip" "test" {
tags {
test_tag = "hello tag"
random_tag = "%d"
}
}
data "aws_eip" "by_tag" {
tags {
test_tag = "${aws_eip.test.tags["test_tag"]}"
random_tag = "%d"
}
}
`, rInt)
}