Skip to content

Commit b6c17a2

Browse files
authored
feat: AppRunner add support for Connections (#3602)
<!-- 🎉 Thank you for making CloudQuery awesome by submitting a PR 🎉 --> #### Summary <!-- Explain what problem this PR addresses --> <!-- Use the following steps to ensure your PR is ready to be reviewed - [ ] Read the [contribution guidelines](../blob/main/CONTRIBUTING.md) 🧑‍🎓 - [ ] Test locally on your own infrastructure - [ ] Run `go fmt` to format your code 🖊 - [ ] Lint your changes via `golangci-lint run` 🚨 (install golangci-lint [here](https://golangci-lint.run/usage/install/#local-installation)) - [ ] Update or add tests 🧪 - [ ] Ensure the status checks below are successful ✅ --->
1 parent 5f1c2eb commit b6c17a2

File tree

7 files changed

+153
-0
lines changed

7 files changed

+153
-0
lines changed

plugins/source/aws/codegen/recipes/apprunner.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ import (
99
func ApprunnerResources() []*Resource {
1010
resources := []*Resource{
1111
{
12+
SubService: "connections",
13+
Struct: &types.ConnectionSummary{},
14+
Description: "https://docs.aws.amazon.com/apprunner/latest/api/API_Connection.html",
15+
SkipFields: []string{"ConnectionArn"},
16+
Multiplex: `client.ServiceAccountRegionMultiplexer("apprunner")`,
17+
ExtraColumns: append(
18+
defaultRegionalColumns,
19+
[]codegen.ColumnDefinition{
20+
{
21+
Name: "arn",
22+
Type: schema.TypeString,
23+
Resolver: `schema.PathResolver("ConnectionArn")`,
24+
Options: schema.ColumnCreationOptions{PrimaryKey: true},
25+
},
26+
}...),
27+
}, {
1228
SubService: "services",
1329
Struct: &types.Service{},
1430
Description: "https://docs.aws.amazon.com/apprunner/latest/api/API_Service.html",

plugins/source/aws/docs/tables/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
|[aws_apigatewayv2_domain_name_rest_api_mappings](aws_apigatewayv2_domain_name_rest_api_mappings.md) |
3535
| [aws_apigatewayv2_vpc_links](aws_apigatewayv2_vpc_links.md) |
3636
| [aws_applicationautoscaling_policies](aws_applicationautoscaling_policies.md) |
37+
| [aws_apprunner_connections](aws_apprunner_connections.md) |
3738
| [aws_apprunner_services](aws_apprunner_services.md) |
3839
|[aws_apprunner_operations](aws_apprunner_operations.md) |
3940
|[aws_apprunner_custom_domains](aws_apprunner_custom_domains.md) |
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Table: aws_apprunner_connections
2+
3+
https://docs.aws.amazon.com/apprunner/latest/api/API_Connection.html
4+
5+
The primary key for this table is **arn**.
6+
7+
8+
## Columns
9+
| Name | Type |
10+
| ------------- | ------------- |
11+
|_cq_source_name|String|
12+
|_cq_sync_time|Timestamp|
13+
|_cq_id|UUID|
14+
|_cq_parent_id|UUID|
15+
|account_id|String|
16+
|region|String|
17+
|arn (PK)|String|
18+
|connection_name|String|
19+
|created_at|Timestamp|
20+
|provider_type|String|
21+
|status|String|

plugins/source/aws/resources/plugin/tables.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/source/aws/resources/services/apprunner/connections.go

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package apprunner
2+
3+
import (
4+
"context"
5+
6+
"github.com/aws/aws-sdk-go-v2/service/apprunner"
7+
"github.com/cloudquery/cloudquery/plugins/source/aws/client"
8+
"github.com/cloudquery/plugin-sdk/schema"
9+
)
10+
11+
func fetchApprunnerConnections(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
12+
var config apprunner.ListConnectionsInput
13+
svc := meta.(*client.Client).Services().Apprunner
14+
paginator := apprunner.NewListConnectionsPaginator(svc, &config)
15+
for paginator.HasMorePages() {
16+
output, err := paginator.NextPage(ctx)
17+
if err != nil {
18+
return err
19+
}
20+
res <- output.ConnectionSummaryList
21+
}
22+
return nil
23+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package apprunner
2+
3+
import (
4+
"testing"
5+
6+
"github.com/aws/aws-sdk-go-v2/service/apprunner"
7+
"github.com/aws/aws-sdk-go-v2/service/apprunner/types"
8+
"github.com/cloudquery/cloudquery/plugins/source/aws/client"
9+
"github.com/cloudquery/cloudquery/plugins/source/aws/client/mocks"
10+
"github.com/cloudquery/plugin-sdk/faker"
11+
"github.com/golang/mock/gomock"
12+
)
13+
14+
func buildConnections(t *testing.T, ctrl *gomock.Controller) client.Services {
15+
m := mocks.NewMockApprunnerClient(ctrl)
16+
s := types.ConnectionSummary{}
17+
err := faker.FakeObject(&s)
18+
if err != nil {
19+
t.Fatal(err)
20+
}
21+
22+
m.EXPECT().ListConnections(gomock.Any(), gomock.Any(), gomock.Any()).Return(
23+
&apprunner.ListConnectionsOutput{
24+
ConnectionSummaryList: []types.ConnectionSummary{s},
25+
}, nil)
26+
27+
return client.Services{
28+
Apprunner: m,
29+
}
30+
}
31+
32+
func TestConnections(t *testing.T) {
33+
client.AwsMockTestHelper(t, Connections(), buildConnections, client.TestOptions{})
34+
}

0 commit comments

Comments
 (0)