github.com/GoogleCloudPlatform/terraformer@v0.8.18/providers/aws/appsync.go (about)

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