-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Add support for tagging aws_dx_lag and aws_dx_connection resources #2990
Changes from 1 commit
5281c8b
60a9812
4a2a9a2
3a2988d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,15 +12,51 @@ import ( | |
) | ||
|
||
func TestAccAwsDxConnection_basic(t *testing.T) { | ||
connectionName := fmt.Sprintf("tf-dx-%s", acctest.RandString(5)) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckAwsDxConnectionDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDxConnectionConfig(connectionName), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAwsDxConnectionExists("aws_dx_connection.hoge"), | ||
resource.TestCheckResourceAttr("aws_dx_connection.hoge", "name", connectionName), | ||
resource.TestCheckResourceAttr("aws_dx_connection.hoge", "bandwidth", "1Gbps"), | ||
resource.TestCheckResourceAttr("aws_dx_connection.hoge", "location", "EqSe2"), | ||
resource.TestCheckResourceAttr("aws_dx_connection.hoge", "tags.%", "0"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAwsDxConnection_tags(t *testing.T) { | ||
connectionName := fmt.Sprintf("tf-dx-%s", acctest.RandString(5)) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckAwsDxConnectionDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDxConnectionConfig(acctest.RandString(5)), | ||
Config: testAccDxConnectionConfig_tags(connectionName), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAwsDxConnectionExists("aws_dx_connection.hoge"), | ||
resource.TestCheckResourceAttr("aws_dx_connection.hoge", "name", connectionName), | ||
resource.TestCheckResourceAttr("aws_dx_connection.hoge", "tags.%", "2"), | ||
resource.TestCheckResourceAttr("aws_dx_connection.hoge", "tags.Usage", "original"), | ||
), | ||
}, | ||
{ | ||
Config: testAccDxConnectionConfig_tagsChanged(connectionName), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAwsDxConnectionExists("aws_dx_connection.hoge"), | ||
resource.TestCheckResourceAttr("aws_dx_connection.hoge", "name", connectionName), | ||
resource.TestCheckResourceAttr("aws_dx_connection.hoge", "tags.%", "1"), | ||
resource.TestCheckResourceAttr("aws_dx_connection.hoge", "tags.Usage", "changed"), | ||
), | ||
}, | ||
}, | ||
|
@@ -63,12 +99,41 @@ func testAccCheckAwsDxConnectionExists(name string) resource.TestCheckFunc { | |
} | ||
} | ||
|
||
func testAccDxConnectionConfig(rName string) string { | ||
func testAccDxConnectionConfig(n string) string { | ||
return fmt.Sprintf(` | ||
resource "aws_dx_connection" "hoge" { | ||
name = "%s" | ||
bandwidth = "1Gbps" | ||
location = "EqSe2" | ||
} | ||
`, n) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: indentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
} | ||
|
||
func testAccDxConnectionConfig_tags(n string) string { | ||
return fmt.Sprintf(` | ||
resource "aws_dx_connection" "hoge" { | ||
name = "%s" | ||
bandwidth = "1Gbps" | ||
location = "EqSe2" | ||
|
||
tags { | ||
Environment = "production" | ||
Usage = "original" | ||
} | ||
} | ||
`, n) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: indentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
} | ||
|
||
func testAccDxConnectionConfig_tagsChanged(n string) string { | ||
return fmt.Sprintf(` | ||
resource "aws_dx_connection" "hoge" { | ||
name = "tf-dx-%s" | ||
bandwidth = "1Gbps" | ||
location = "EqSe2" | ||
} | ||
`, rName) | ||
resource "aws_dx_connection" "hoge" { | ||
name = "%s" | ||
bandwidth = "1Gbps" | ||
location = "EqSe2" | ||
|
||
tags { | ||
Usage = "changed" | ||
} | ||
} | ||
`, n) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: indentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be ok with removing the resource from state if it's in
ConnectionStateDeleted
, but I think we should keep it in the state if it's stillConnectionStateDeleting
orConnectionStateRejected
. The deletion may not finish successfully and rejection != deleted resource, AFAIK?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, agreed. I'll fix.