forked from GoogleCloudPlatform/terraformer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
appsync.go
48 lines (40 loc) · 848 Bytes
/
appsync.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package aws
import (
"context"
"github.com/GoogleCloudPlatform/terraformer/terraformutils"
"github.com/aws/aws-sdk-go-v2/service/appsync"
)
type AppSyncGenerator struct {
AWSService
}
func (g *AppSyncGenerator) InitResources() error {
config, e := g.generateConfig()
if e != nil {
return e
}
svc := appsync.NewFromConfig(config)
var nextToken *string
for {
apis, err := svc.ListGraphqlApis(context.TODO(), &appsync.ListGraphqlApisInput{
NextToken: nextToken,
})
if err != nil {
return err
}
for _, api := range apis.GraphqlApis {
var id = *api.ApiId
var name = *api.Name
g.Resources = append(g.Resources, terraformutils.NewSimpleResource(
id,
name,
"aws_appsync_graphql_api",
"aws",
[]string{}))
}
nextToken = apis.NextToken
if nextToken == nil {
break
}
}
return nil
}