-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Conversation
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.
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 |
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.
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.
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.
Good idea.
Changing now.
}) | ||
} | ||
|
||
func testAccDataSourceAwsApiGatewayResourceCheck(name string) resource.TestCheckFunc { |
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.
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"),
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.
Pro tip! Thanks!
"github.com/hashicorp/terraform/terraform" | ||
) | ||
|
||
func TestDataSourceAwsApiGatewayResource(t *testing.T) { |
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.
For acceptance tests the convention is to prefix them with TestAcc
👍
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.
Aye, will do.
@bflad I updated based on your great comments. I reverified acceptance tests pass. |
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.
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
Super fast! Thanks @bflad! |
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. |
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! |
Changes proposed in this pull request:
data.aws_api_gateway_resource
.Output from acceptance testing: