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

Created data source aws_api_gateway_resource #5629

Merged
merged 8 commits into from
Aug 21, 2018

Conversation

BSick7
Copy link
Contributor

@BSick7 BSick7 commented Aug 21, 2018

Changes proposed in this pull request:

  • Create data.aws_api_gateway_resource.

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccDataSourceAwsApiGatewayResource'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -run=TestDataSourceAwsApiGatewayResource -timeout 120m
?       github.com/terraform-providers/terraform-provider-aws   [no test files]
=== RUN   TestDataSourceAwsApiGatewayResource
--- PASS: TestDataSourceAwsApiGatewayResource (17.08s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       (cached)

@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Aug 21, 2018
@bflad bflad added new-data-source Introduces a new data source. service/apigateway Issues and PRs that pertain to the apigateway service. labels Aug 21, 2018
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.

Thanks for submitting this, @BSick7! Looking pretty good, just left some initial comments below. Can you please take a look and let us know if you have any questions? Thanks!

target := d.Get("path").(string)
params := &apigateway.GetResourcesInput{RestApiId: aws.String(restApiId)}

var matches []*apigateway.Resource
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to have multiple resources at the same path? If not, we should change this to be singular and return false in the GetResourcesPages after it matches to save API calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea.
Changing now.

})
}

func testAccDataSourceAwsApiGatewayResourceCheck(name string) resource.TestCheckFunc {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can skip creating this additional function by using the resource.TestCheckResourceAttrPair() helper function, e.g.

resourceName := "aws_api_gateway_resource.example_v1"
dataSourceName := "data.aws_api_gateway_resource.example_v1"
// ...
resource.TestCheckResourceAttrPair(resourceName, "id", dataSourceName, "id"),
resource.TestCheckResourceAttrPair(resourceName, "parent_id", dataSourceName, "parent_id"),
resource.TestCheckResourceAttrPair(resourceName, "path_part", dataSourceName, "path_part"),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pro tip! Thanks!

"github.com/hashicorp/terraform/terraform"
)

func TestDataSourceAwsApiGatewayResource(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

For acceptance tests the convention is to prefix them with TestAcc 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aye, will do.

@BSick7
Copy link
Contributor Author

BSick7 commented Aug 21, 2018

@bflad I updated based on your great comments. I reverified acceptance tests pass.

@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Aug 21, 2018
@bflad bflad added this to the v1.33.0 milestone Aug 21, 2018
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.

LGTM! 🚀 (I also forgot to mention we need a new documentation website sidebar link in website/aws.erb -- I will add it after merge since that was my mistake)

make testacc TEST=./aws TESTARGS='-run=TestAccDataSourceAwsApiGatewayResource'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccDataSourceAwsApiGatewayResource -timeout 120m
=== RUN   TestAccDataSourceAwsApiGatewayResource
--- PASS: TestAccDataSourceAwsApiGatewayResource (18.42s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	19.041s

@bflad bflad merged commit 92342fd into hashicorp:master Aug 21, 2018
bflad added a commit that referenced this pull request Aug 21, 2018
@BSick7
Copy link
Contributor Author

BSick7 commented Aug 21, 2018

Super fast! Thanks @bflad!

@BSick7 BSick7 deleted the f-aws_api_gateway_resource branch August 21, 2018 17:53
@bflad
Copy link
Contributor

bflad commented Aug 22, 2018

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

@ghost
Copy link

ghost commented Apr 3, 2020

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 and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-data-source Introduces a new data source. service/apigateway Issues and PRs that pertain to the apigateway service. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants