-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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 tag support for aws_codestarconnections_connection resource #16835
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,33 @@ func TestAccAWSCodeStarConnectionsConnection_disappears(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccAWSCodeStarConnectionsConnection_tags(t *testing.T) { | ||
var v codestarconnections.Connection | ||
resourceName := "aws_codestarconnections_connection.test" | ||
rName := acctest.RandomWithPrefix("tf-acc-test") | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(codestarconnections.EndpointsID, t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckAWSCodeStarConnectionsConnectionDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccAWSCodeStarConnectionsConnectionConfigTags(rName), | ||
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. Nit: Will parameterize this to match the Contributing Guide so it is easier to add the update step. |
||
Check: resource.ComposeAggregateTestCheckFunc( | ||
testAccCheckAWSCodeStarConnectionsConnectionExists(resourceName, &v), | ||
resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), | ||
resource.TestCheckResourceAttr(resourceName, "tags.Environment", "production"), | ||
), | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckAWSCodeStarConnectionsConnectionExists(n string, v *codestarconnections.Connection) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
rs, ok := s.RootModule().Resources[n] | ||
|
@@ -118,3 +145,17 @@ resource "aws_codestarconnections_connection" "test" { | |
} | ||
`, rName) | ||
} | ||
|
||
func testAccAWSCodeStarConnectionsConnectionConfigTags(rName string) string { | ||
return fmt.Sprintf(` | ||
resource "aws_codestarconnections_connection" "test" { | ||
name = %[1]q | ||
provider_type = "Bitbucket" | ||
|
||
tags = { | ||
Name = %[1]q | ||
Environment = "production" | ||
} | ||
} | ||
`, rName) | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -68,6 +68,7 @@ The following arguments are supported: | |||||
|
||||||
* `name` - (Required) The name of the connection to be created. The name must be unique in the calling AWS account. Changing `name` will create a new resource. | ||||||
* `provider_type` - (Required) The name of the external provider where your third-party code repository is configured. Valid values are `Bitbucket`, `GitHub`, or `GitHubEnterpriseServer`. Changing `provider_type` will create a new resource. | ||||||
* `tags` - (Optional) An array of key:value pairs to associate with the resource. | ||||||
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. In Terraform the type is
Suggested change
|
||||||
|
||||||
## Attributes Reference | ||||||
|
||||||
|
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.
Updating resource tags should not require resource recreation -- we can add an
Update
function that only handlestags
. 👍