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

Add CodeStar Connection data source #18129

Merged

Conversation

shuheiktgw
Copy link
Collaborator

@shuheiktgw shuheiktgw commented Mar 16, 2021

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates #15453

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccDataSourceAwsCodeStarConnectionsConnection_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccDataSourceAwsCodeStarConnectionsConnection_ -timeout 180m
=== RUN   TestAccDataSourceAwsCodeStarConnectionsConnection_basic
=== PAUSE TestAccDataSourceAwsCodeStarConnectionsConnection_basic
=== RUN   TestAccDataSourceAwsCodeStarConnectionsConnection_tags
=== PAUSE TestAccDataSourceAwsCodeStarConnectionsConnection_tags
=== CONT  TestAccDataSourceAwsCodeStarConnectionsConnection_basic
=== CONT  TestAccDataSourceAwsCodeStarConnectionsConnection_tags
--- PASS: TestAccDataSourceAwsCodeStarConnectionsConnection_basic (37.21s)
--- PASS: TestAccDataSourceAwsCodeStarConnectionsConnection_tags (37.29s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	39.177s

Added CodeStar Connection data source. Thank you for your review!

@ghost ghost added size/M Managed by automation to categorize the size of a PR. provider Pertains to the provider itself, rather than any interaction with AWS. service/codestarconnections Issues and PRs that pertain to the codestarconnections service. labels Mar 16, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Mar 16, 2021
@shuheiktgw shuheiktgw force-pushed the add_codestarconnections_connection_data_source branch from 7e4ae2f to dbcccdf Compare March 16, 2021 23:49
@ghost ghost added size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. documentation Introduces or discusses updates to documentation. and removed size/M Managed by automation to categorize the size of a PR. labels Mar 17, 2021
@shuheiktgw shuheiktgw marked this pull request as ready for review March 17, 2021 23:50
@shuheiktgw shuheiktgw requested a review from a team as a code owner March 17, 2021 23:50
@bflad bflad added new-data-source Introduces a new data source. and removed needs-triage Waiting for first response or review from a maintainer. labels Mar 19, 2021
@bflad bflad self-assigned this Mar 19, 2021
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor testing updates, otherwise this is looking really good, thank you @shuheiktgw 🎉

Comment on lines 18 to 19
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(codestarconnections.EndpointsID, t) },
Providers: testAccProviders,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are currently in the process of adding ErrorCheck to each of the acceptance tests. Reference: #18175

Can you please add this here? Thank you!

Suggested change
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(codestarconnections.EndpointsID, t) },
Providers: testAccProviders,
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(codestarconnections.EndpointsID, t) },
ErrorCheck: testAccErrorCheck(t, codestarconnections.EndpointsID),
Providers: testAccProviders,

Comment on lines 24 to 28
testAccMatchResourceAttrRegionalARN(resourceName, "id", "codestar-connections", regexp.MustCompile("connection/.+")),
testAccMatchResourceAttrRegionalARN(resourceName, "arn", "codestar-connections", regexp.MustCompile("connection/.+")),
resource.TestCheckResourceAttr(resourceName, "provider_type", codestarconnections.ProviderTypeBitbucket),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "connection_status", codestarconnections.ConnectionStatusPending),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For data source testing, we prefer using resource.TestCheckResourceAttrPair() where possible to simplify it. 👍 Reference: https://github.com/hashicorp/terraform-provider-aws/blob/main/docs/contributing/running-and-writing-acceptance-tests.md#data-source-acceptance-testing

Suggested change
testAccMatchResourceAttrRegionalARN(resourceName, "id", "codestar-connections", regexp.MustCompile("connection/.+")),
testAccMatchResourceAttrRegionalARN(resourceName, "arn", "codestar-connections", regexp.MustCompile("connection/.+")),
resource.TestCheckResourceAttr(resourceName, "provider_type", codestarconnections.ProviderTypeBitbucket),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "connection_status", codestarconnections.ConnectionStatusPending),
resource.TestCheckResourceAttrPair(dataSourceName, "arn", resourceName, "arn"),
resource.TestCheckResourceAttrPair(dataSourceName, "connection_status", resourceName, "connection_status"),
resource.TestCheckResourceAttrPair(dataSourceName, "id", resourceName, "id"),
resource.TestCheckResourceAttrPair(dataSourceName, "provider_type", resourceName, "provider_type"),
resource.TestCheckResourceAttrPair(dataSourceName, "name", resourceName, "name"),
resource.TestCheckResourceAttrPair(dataSourceName, "tags.%", resourceName, "tags.%"),


func TestAccDataSourceAwsCodeStarConnectionsConnection_basic(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "data.aws_codestarconnections_connection.test"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it can be referenced below 😄

Suggested change
resourceName := "data.aws_codestarconnections_connection.test"
dataSourceName := "data.aws_codestarconnections_connection.test"
resourceName := "aws_codestarconnections_connection.test"


func TestAccDataSourceAwsCodeStarConnectionsConnection_tags(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "data.aws_codestarconnections_connection.test"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly:

Suggested change
resourceName := "data.aws_codestarconnections_connection.test"
dataSourceName := "data.aws_codestarconnections_connection.test"
resourceName := "aws_codestarconnections_connection.test"

Comment on lines 40 to 41
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(codestarconnections.EndpointsID, t) },
Providers: testAccProviders,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly:

Suggested change
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(codestarconnections.EndpointsID, t) },
Providers: testAccProviders,
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(codestarconnections.EndpointsID, t) },
ErrorCheck: testAccErrorCheck(t, codestarconnections.EndpointsID),
Providers: testAccProviders,

Comment on lines 46 to 48
resource.TestCheckResourceAttr(resourceName, "tags.%", "2"),
resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"),
resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
resource.TestCheckResourceAttr(resourceName, "tags.%", "2"),
resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"),
resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"),
resource.TestCheckResourceAttrPair(dataSourceName, "tags.%", resourceName, "tags.%"),

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Mar 19, 2021
@shuheiktgw shuheiktgw force-pushed the add_codestarconnections_connection_data_source branch from adcc7ed to 48142f8 Compare March 19, 2021 02:39
@shuheiktgw
Copy link
Collaborator Author

Thanks, @bflad! Updated the tests, so would you review the PR again?

$ make testacc TESTARGS='-run=TestAccDataSourceAwsCodeStarConnectionsConnection_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccDataSourceAwsCodeStarConnectionsConnection_ -timeout 180m
go: downloading github.com/hashicorp/go-multierror v1.1.1
=== RUN   TestAccDataSourceAwsCodeStarConnectionsConnection_basic
=== PAUSE TestAccDataSourceAwsCodeStarConnectionsConnection_basic
=== RUN   TestAccDataSourceAwsCodeStarConnectionsConnection_tags
=== PAUSE TestAccDataSourceAwsCodeStarConnectionsConnection_tags
=== CONT  TestAccDataSourceAwsCodeStarConnectionsConnection_basic
=== CONT  TestAccDataSourceAwsCodeStarConnectionsConnection_tags
--- PASS: TestAccDataSourceAwsCodeStarConnectionsConnection_basic (45.73s)
--- PASS: TestAccDataSourceAwsCodeStarConnectionsConnection_tags (68.08s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	69.859s

@ghost ghost removed waiting-response Maintainers are waiting on response from community or contributor. labels Mar 19, 2021
@shuheiktgw shuheiktgw requested a review from bflad March 19, 2021 04:56
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 🚀 (Forgot to mention adding a changelog entry before 😅 will do so on merge)

Output from acceptance testing:

--- PASS: TestAccDataSourceAwsCodeStarConnectionsConnection_basic (19.66s)
--- PASS: TestAccDataSourceAwsCodeStarConnectionsConnection_tags (19.69s)

--- PASS: TestAccAWSCodeStarConnectionsConnection_disappears (12.08s)
--- PASS: TestAccAWSCodeStarConnectionsConnection_Basic (16.27s)
--- PASS: TestAccAWSCodeStarConnectionsConnection_Tags (35.69s)

@bflad bflad merged commit a652d4a into hashicorp:main Mar 19, 2021
@github-actions github-actions bot added this to the v3.34.0 milestone Mar 19, 2021
bflad added a commit that referenced this pull request Mar 19, 2021
@shuheiktgw shuheiktgw deleted the add_codestarconnections_connection_data_source branch March 21, 2021 05:18
@shuheiktgw
Copy link
Collaborator Author

Thank you for your review, @bflad!

@ghost
Copy link

ghost commented Mar 26, 2021

This has been released in version 3.34.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Apr 18, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Apr 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. new-data-source Introduces a new data source. provider Pertains to the provider itself, rather than any interaction with AWS. service/codestarconnections Issues and PRs that pertain to the codestarconnections service. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants