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 new data source aws_api_gateway_rest_api #4172

Merged
merged 3 commits into from
Apr 12, 2018

Conversation

timborrowdale
Copy link
Contributor

#4146

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

I've had issues trying to get the terraform-website project working to check the docs locally - I think they're ok but would be good if someone could check.

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

Hi @timborrowdale 👋 Thanks for this contribution. I left some initial comments below. Can you please take a look and let me know if you have any questions?

Type: schema.TypeString,
Required: true,
},
"id": {
Copy link
Contributor

Choose a reason for hiding this comment

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

id does not need to be declared as a schema attribute 👍

matchedApis = append(matchedApis, api)
}
}
return true
Copy link
Contributor

Choose a reason for hiding this comment

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

Should use return !lastPage here

log.Printf("[DEBUG] Reading API Gateway REST APIs: %s", params)
err := conn.GetRestApisPages(params, func(page *apigateway.GetRestApisOutput, lastPage bool) bool {
for _, api := range page.Items {
if *api.Name == target {
Copy link
Contributor

Choose a reason for hiding this comment

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

To prevent a potential crash, we should wrap this with aws.StringValue(api.Name) in the unlikely scenario that its returned as nil

return true
})
if err != nil {
return errwrap.Wrapf("error describing API Gateway REST APIs: {{err}}", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

We do not need the context of the error when returning a message back to the user here. We can use the simpler fmt.Errorf("error describing API Gateway REST APIs: %s", err) here 👍


d.SetId(*match.Id)

if err = dataSourceAwsApiGatewayRestApiRefreshResources(d, meta); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

We do not need the extra function here, its contents can be included in the read function 👍

}

const testAccDataSourceAwsApiGatewayRestApiConfig = `
provider "aws" {
Copy link
Contributor

Choose a reason for hiding this comment

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

We do not need to declare the provider block in the testing framework, it defaults to us-west-2 if not provided via AWS_DEFAULT_REGION

}

resource "aws_api_gateway_rest_api" "tf_test" {
name = "tf_test"
Copy link
Contributor

Choose a reason for hiding this comment

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

These should have randomized names to prevent hitting the multiple match error condition after test panics/AWS failures. Usually we achieve this by wrapping the test configuration in fmt.Sprintf() and passing a randomized name from the test function, e.g. rName := acctest.StringWithPrefix("tf_acc_test_")

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Apr 11, 2018
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Apr 12, 2018
@timborrowdale
Copy link
Contributor Author

@bflad Thanks for the feedback - I've had a go at addressing those issues.

@bflad bflad removed the waiting-response Maintainers are waiting on response from community or contributor. label Apr 12, 2018
@bflad bflad added this to the v1.15.0 milestone Apr 12, 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.

Awesome job, LGTM! 🚀

1 test passed (all tests)
=== RUN   TestAccDataSourceAwsApiGatewayRestApi
--- PASS: TestAccDataSourceAwsApiGatewayRestApi (8.06s)

@bflad bflad merged commit 3c05780 into hashicorp:master Apr 12, 2018
bflad added a commit that referenced this pull request Apr 12, 2018
@bflad
Copy link
Contributor

bflad commented Apr 18, 2018

This has been released in version 1.15.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 6, 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 6, 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