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

Fixes root_resource_id not being set on Api Gateway Rest API data source #11705

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions aws/data_source_aws_api_gateway_rest_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,22 @@ func dataSourceAwsApiGatewayRestApiRead(d *schema.ResourceData, meta interface{}

d.SetId(*match.Id)

resp, err := conn.GetResources(&apigateway.GetResourcesInput{
resourceParams := &apigateway.GetResourcesInput{
RestApiId: aws.String(d.Id()),
})
if err != nil {
return err
}

for _, item := range resp.Items {
if *item.Path == "/" {
d.Set("root_resource_id", item.Id)
break
err = conn.GetResourcesPages(resourceParams, func(page *apigateway.GetResourcesOutput, lastPage bool) bool {
for _, item := range page.Items {
if *item.Path == "/" {
d.Set("root_resource_id", item.Id)
return false
}
}
return !lastPage
})

if 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.

why not just return err? :-)

return err
}

return nil
Expand Down