client

package
v0.0.0-...-8717a7e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2025 License: MPL-2.0 Imports: 158 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PartitionServiceRegionFile = "data/partition_service_region.json"
)

Variables

View Source
var AllAWSServiceNames = [...]string{}/* 120 elements not displayed */
View Source
var AllNamespaces = []string{
	"comprehend", "rds", "sagemaker", "appstream", "elasticmapreduce", "dynamodb", "lambda", "ecs", "cassandra", "ec2", "neptune", "kafka", "custom-resource", "elasticache",
}
View Source
var ErrPaidAPIsNotEnabled = errors.New("not fetching resource because `use_paid_apis` is set to false")

Functions

func AccountMultiplex

func AccountMultiplex(table string) func(meta schema.ClientMeta) []schema.ClientMeta

func AwsMockTestHelper

func AwsMockTestHelper(t *testing.T, parentTable *schema.Table, builder func(*testing.T, *gomock.Controller) Services, testOpts TestOptions)

func Configure

func Configure(ctx context.Context, logger zerolog.Logger, s spec.Spec) (schema.ClientMeta, error)

Configure is the entrypoint into configuring the AWS plugin. It is called by the plugin initialization in resources/plugin/aws.go

func ConfigureAwsSDK

func ConfigureAwsSDK(ctx context.Context, logger zerolog.Logger, awsPluginSpec *spec.Spec, account spec.Account, stsClient AssumeRoleAPIClient) (aws.Config, error)

func CreateReplaceTransformer

func CreateReplaceTransformer(replace map[string]string) func(field reflect.StructField) (string, error)

func CreateTrimPrefixTransformer

func CreateTrimPrefixTransformer(prefixes ...string) func(field reflect.StructField) (string, error)

func DefaultAccountIDColumn

func DefaultAccountIDColumn(pk bool) schema.Column

func DefaultRegionColumn

func DefaultRegionColumn(pk bool) schema.Column

func IgnoreAccessDeniedServiceDisabled

func IgnoreAccessDeniedServiceDisabled(err error) bool

func IgnoreCommonErrors

func IgnoreCommonErrors(err error) bool

func IgnoreNotAvailableRegion

func IgnoreNotAvailableRegion(err error) bool

func IgnoreWithInvalidAction

func IgnoreWithInvalidAction(err error) bool

func IsAWSError

func IsAWSError(err error, code ...string) bool

func IsInvalidParameterValueError

func IsInvalidParameterValueError(err error) bool

func LanguageCodeColumn

func LanguageCodeColumn(pk bool) schema.Column

func RegionsPartition

func RegionsPartition(region string) (string, bool)

func RequestAccountIDColumn

func RequestAccountIDColumn(pk bool) schema.Column

func RequestRegionColumn

func RequestRegionColumn(pk bool) schema.Column

func ResolveARN

func ResolveARN(service AWSService, resourceID func(resource *schema.Resource) ([]string, error)) schema.ColumnResolver

ResolveARN returns a column resolver that will set a field value to a proper ARN based on provided AWS service and resource id value returned by resourceID function. Region and account id are set to the values of the client.

func ResolveARNGlobal

func ResolveARNGlobal(service AWSService, resourceID func(resource *schema.Resource) ([]string, error)) schema.ColumnResolver

ResolveARNGlobal returns a column resolver that will set a field value to a proper ARN based on provided AWS service and resource id value returned by resourceID function. Region and account id are left empty.

func ResolveARNWithAccount

func ResolveARNWithAccount(service AWSService, resourceID func(resource *schema.Resource) ([]string, error)) schema.ColumnResolver

ResolveARNWithAccount returns a column resolver that will set a field value to a proper ARN based on provided AWS service and resource id value returned by resourceID function. Region is left empty and account id is set to the value of the client.

func ResolveAWSAccount

func ResolveAWSAccount(_ context.Context, meta schema.ClientMeta, r *schema.Resource, c schema.Column) error

func ResolveAWSNamespace

func ResolveAWSNamespace(_ context.Context, meta schema.ClientMeta, r *schema.Resource, c schema.Column) error

func ResolveAWSPartition

func ResolveAWSPartition(_ context.Context, meta schema.ClientMeta, r *schema.Resource, c schema.Column) error

func ResolveAWSRegion

func ResolveAWSRegion(_ context.Context, meta schema.ClientMeta, r *schema.Resource, c schema.Column) error

func ResolveLanguageCode

func ResolveLanguageCode(_ context.Context, meta schema.ClientMeta, r *schema.Resource, c schema.Column) error

func ResolveTagPath

func ResolveTagPath(fieldPath string) func(context.Context, schema.ClientMeta, *schema.Resource, schema.Column) error

func ResolveTags

func ResolveTags(ctx context.Context, meta schema.ClientMeta, r *schema.Resource, c schema.Column) error

func ResolveWAFScope

func ResolveWAFScope(_ context.Context, meta schema.ClientMeta, r *schema.Resource, c schema.Column) error

func ServiceAccountRegionMultiplexer

func ServiceAccountRegionMultiplexer(table, service string) func(meta schema.ClientMeta) []schema.ClientMeta

func ServiceAccountRegionNamespaceMultiplexer

func ServiceAccountRegionNamespaceMultiplexer(table, service string) func(meta schema.ClientMeta) []schema.ClientMeta

func ServiceAccountRegionScopeMultiplexer

func ServiceAccountRegionScopeMultiplexer(table, service string) func(meta schema.ClientMeta) []schema.ClientMeta

func ServiceAccountRegionsLanguageCodeMultiplex

func ServiceAccountRegionsLanguageCodeMultiplex(table, service string, codes []string) func(meta schema.ClientMeta) []schema.ClientMeta

func Sleep

func Sleep(ctx context.Context, dur time.Duration) error

func TagsIntoMap

func TagsIntoMap(tagSlice any, dst map[string]string)

TagsIntoMap expects []T (usually "[]Tag") where T has "Key" and "Value" fields (of type string or *string) and writes them into the given map

func TagsResolverTransformer

func TagsResolverTransformer(field reflect.StructField, path string) schema.ColumnResolver

TagsResolverTransformer adds possibility to override the column resolver for "Tags" field

func TagsToMap

func TagsToMap(tagSlice any) map[string]string

TagsToMap expects []T (usually "[]Tag") where T has "Key" and "Value" fields (of type string or *string) and returns a map

func TimestampResolverTransformer

func TimestampResolverTransformer(field reflect.StructField, path string) schema.ColumnResolver

func TimestampTypeTransformer

func TimestampTypeTransformer(field reflect.StructField) (arrow.DataType, error)

Types

type AWSService

type AWSService string
const (
	ApigatewayService           AWSService = "apigateway"
	AppconfigService            AWSService = "appconfig"
	AthenaService               AWSService = "athena"
	CloudformationService       AWSService = "cloudformation"
	CloudfrontService           AWSService = "cloudfront"
	CognitoIdentityService      AWSService = "cognito-identity"
	DirectConnectService        AWSService = "directconnect"
	DynamoDBService             AWSService = "dynamodb"
	EC2Service                  AWSService = "ec2"
	EFSService                  AWSService = "elasticfilesystem"
	ElasticLoadBalancingService AWSService = "elasticloadbalancing"
	GlueService                 AWSService = "glue"
	GuardDutyService            AWSService = "guardduty"
	IamService                  AWSService = "iam"
	IdentitystoreService        AWSService = "identitystore"
	RedshiftService             AWSService = "redshift"
	Route53Service              AWSService = "route53"
	S3Service                   AWSService = "s3"
	SESService                  AWSService = "ses"
	WAFRegional                 AWSService = "waf-regional"
	WorkspacesService           AWSService = "workspaces"
	XRayService                 AWSService = "xray"
	RDSService                  AWSService = "rds"
)

type AWSServiceName

type AWSServiceName int
const (
	AWSServiceAccessanalyzer AWSServiceName = iota
	AWSServiceAccount
	AWSServiceAcm
	AWSServiceAcmpca
	AWSServiceAmp
	AWSServiceAmplify
	AWSServiceApigateway
	AWSServiceApigatewayv2
	AWSServiceAppconfig
	AWSServiceAppflow
	AWSServiceApplicationautoscaling
	AWSServiceAppmesh
	AWSServiceApprunner
	AWSServiceAppstream
	AWSServiceAppsync
	AWSServiceAthena
	AWSServiceAuditmanager
	AWSServiceAutoscaling
	AWSServiceAutoscalingplans
	AWSServiceBackup
	AWSServiceBatch
	AWSServiceCloudformation
	AWSServiceCloudfront
	AWSServiceCloudhsmv2
	AWSServiceCloudtrail
	AWSServiceCloudwatch
	AWSServiceCloudwatchlogs
	AWSServiceCodeartifact
	AWSServiceCodebuild
	AWSServiceCodecommit
	AWSServiceCodepipeline
	AWSServiceCognitoidentity
	AWSServiceCognitoidentityprovider
	AWSServiceComputeoptimizer
	AWSServiceConfigservice
	AWSServiceCostexplorer
	AWSServiceDatabasemigrationservice
	AWSServiceDax
	AWSServiceDetective
	AWSServiceDirectconnect
	AWSServiceDocdb
	AWSServiceDynamodb
	AWSServiceDynamodbstreams
	AWSServiceEc2
	AWSServiceEcr
	AWSServiceEcrpublic
	AWSServiceEcs
	AWSServiceEfs
	AWSServiceEks
	AWSServiceElasticache
	AWSServiceElasticbeanstalk
	AWSServiceElasticloadbalancing
	AWSServiceElasticloadbalancingv2
	AWSServiceElasticsearchservice
	AWSServiceElastictranscoder
	AWSServiceEmr
	AWSServiceEventbridge
	AWSServiceFirehose
	AWSServiceFrauddetector
	AWSServiceFsx
	AWSServiceGlacier
	AWSServiceGlue
	AWSServiceGuardduty
	AWSServiceIam
	AWSServiceIdentitystore
	AWSServiceInspector
	AWSServiceInspector2
	AWSServiceIot
	AWSServiceKafka
	AWSServiceKinesis
	AWSServiceKms
	AWSServiceLambda
	AWSServiceLightsail
	AWSServiceMq
	AWSServiceMwaa
	AWSServiceNeptune
	AWSServiceNetworkfirewall
	AWSServiceNetworkmanager
	AWSServiceOrganizations
	AWSServiceQldb
	AWSServiceQuicksight
	AWSServiceRam
	AWSServiceRds
	AWSServiceRedshift
	AWSServiceResiliencehub
	AWSServiceResourcegroups
	AWSServiceRoute53
	AWSServiceRoute53domains
	AWSServiceRoute53recoverycontrolconfig
	AWSServiceRoute53recoveryreadiness
	AWSServiceRoute53resolver
	AWSServiceS3
	AWSServiceS3control
	AWSServiceSagemaker
	AWSServiceSavingsplans
	AWSServiceScheduler
	AWSServiceSecretsmanager
	AWSServiceSecurityhub
	AWSServiceServicecatalog
	AWSServiceServicecatalogappregistry
	AWSServiceServicediscovery
	AWSServiceServicequotas
	AWSServiceSes
	AWSServiceSesv2
	AWSServiceSfn
	AWSServiceShield
	AWSServiceSigner
	AWSServiceSns
	AWSServiceSqs
	AWSServiceSsm
	AWSServiceSsoadmin
	AWSServiceSupport
	AWSServiceTimestreamwrite
	AWSServiceTransfer
	AWSServiceWaf
	AWSServiceWafregional
	AWSServiceWafv2
	AWSServiceWellarchitected
	AWSServiceWorkspaces
	AWSServiceXray
)

func (AWSServiceName) String

func (s AWSServiceName) String() string

type AssumeRoleAPIClient

type AssumeRoleAPIClient interface {
	AssumeRole(ctx context.Context, params *sts.AssumeRoleInput, optFns ...func(*sts.Options)) (*sts.AssumeRoleOutput, error)
}

type AwsLogger

type AwsLogger struct {
	// contains filtered or unexported fields
}

func (AwsLogger) Logf

func (a AwsLogger) Logf(classification logging.Classification, format string, v ...any)

type AwsPartition

type AwsPartition struct {
	Id       string                 `json:"partition"`
	Name     string                 `json:"partitionName"`
	Services map[string]*AwsService `json:"services"`
}

type AwsService

type AwsService struct {
	Regions map[string]*map[string]any `json:"regions"`
}

type Client

type Client struct {
	// Those are already normalized values after configure and this is why we don't want to hold
	// config directly.
	ServicesManager *ServicesManager

	// this is set by table clientList
	AccountID            string
	Region               string
	AutoscalingNamespace string
	WAFScope             wafv2types.Scope
	Partition            string
	LanguageCode         string

	Spec *spec.Spec
	// contains filtered or unexported fields
}

func AwsCreateMockClient

func AwsCreateMockClient(t *testing.T, ctrl *gomock.Controller, builder func(*testing.T, *gomock.Controller) Services, testOpts TestOptions) Client

func NewAwsClient

func NewAwsClient(logger zerolog.Logger, s *spec.Spec) Client

func (*Client) Duplicate

func (c *Client) Duplicate() *Client

func (*Client) ID

func (c *Client) ID() string

func (*Client) IsNotFoundError

func (c *Client) IsNotFoundError(err error) bool

IsNotFoundError checks if api error should be ignored

func (*Client) Logger

func (c *Client) Logger() *zerolog.Logger

func (*Client) Services

func (c *Client) Services(service_names ...AWSServiceName) *Services

func (*Client) SetStateClient

func (c *Client) SetStateClient(client state.Client)

SetStateClient will set state.Client value (or state.NopClient if the param is nil) to the current Client state backend.

func (*Client) StateClient

func (c *Client) StateClient() state.Client

type DetailResolverFunc

type DetailResolverFunc func(ctx context.Context, meta schema.ClientMeta, resultsChan chan<- any, errorChan chan<- error, summary any)

DetailResolveFunc is responsible for grabbing any and all metadata for a resource. All errors should be sent to the error channel.

type ListResolverFunc

type ListResolverFunc func(ctx context.Context, meta schema.ClientMeta, detailChan chan<- any) error

ListResolver is responsible for iterating through entire list of resources that should be grabbed (if API is paginated). It should send list of items via the `resultsChan` so that the DetailResolver can grab the details of each item. All errors should be sent to the error channel.

type NoRateLimiter

type NoRateLimiter struct {
}

func (*NoRateLimiter) AddTokens

func (*NoRateLimiter) AddTokens(uint) error

func (*NoRateLimiter) GetToken

func (*NoRateLimiter) GetToken(ctx context.Context, cost uint) (func() error, error)

type Services

type Services struct {
	AWSConfig                    aws.Config
	Regions                      []string
	Accessanalyzer               services.AccessanalyzerClient
	Account                      services.AccountClient
	Acm                          services.AcmClient
	Acmpca                       services.AcmpcaClient
	Amp                          services.AmpClient
	Amplify                      services.AmplifyClient
	Apigateway                   services.ApigatewayClient
	Apigatewayv2                 services.Apigatewayv2Client
	Appconfig                    services.AppconfigClient
	Appflow                      services.AppflowClient
	Applicationautoscaling       services.ApplicationautoscalingClient
	Appmesh                      services.AppmeshClient
	Apprunner                    services.ApprunnerClient
	Appstream                    services.AppstreamClient
	Appsync                      services.AppsyncClient
	Athena                       services.AthenaClient
	Auditmanager                 services.AuditmanagerClient
	Autoscaling                  services.AutoscalingClient
	Autoscalingplans             services.AutoscalingplansClient
	Backup                       services.BackupClient
	Batch                        services.BatchClient
	Cloudformation               services.CloudformationClient
	Cloudfront                   services.CloudfrontClient
	Cloudhsmv2                   services.Cloudhsmv2Client
	Cloudtrail                   services.CloudtrailClient
	Cloudwatch                   services.CloudwatchClient
	Cloudwatchlogs               services.CloudwatchlogsClient
	Codeartifact                 services.CodeartifactClient
	Codebuild                    services.CodebuildClient
	Codecommit                   services.CodecommitClient
	Codepipeline                 services.CodepipelineClient
	Cognitoidentity              services.CognitoidentityClient
	Cognitoidentityprovider      services.CognitoidentityproviderClient
	Computeoptimizer             services.ComputeoptimizerClient
	Configservice                services.ConfigserviceClient
	Costexplorer                 services.CostexplorerClient
	Databasemigrationservice     services.DatabasemigrationserviceClient
	Dax                          services.DaxClient
	Detective                    services.DetectiveClient
	Directconnect                services.DirectconnectClient
	Docdb                        services.DocdbClient
	Dynamodb                     services.DynamodbClient
	Dynamodbstreams              services.DynamodbstreamsClient
	Ec2                          services.Ec2Client
	Ecr                          services.EcrClient
	Ecrpublic                    services.EcrpublicClient
	Ecs                          services.EcsClient
	Efs                          services.EfsClient
	Eks                          services.EksClient
	Elasticache                  services.ElasticacheClient
	Elasticbeanstalk             services.ElasticbeanstalkClient
	Elasticloadbalancing         services.ElasticloadbalancingClient
	Elasticloadbalancingv2       services.Elasticloadbalancingv2Client
	Elasticsearchservice         services.ElasticsearchserviceClient
	Elastictranscoder            services.ElastictranscoderClient
	Emr                          services.EmrClient
	Eventbridge                  services.EventbridgeClient
	Firehose                     services.FirehoseClient
	Frauddetector                services.FrauddetectorClient
	Fsx                          services.FsxClient
	Glacier                      services.GlacierClient
	Glue                         services.GlueClient
	Guardduty                    services.GuarddutyClient
	Iam                          services.IamClient
	Identitystore                services.IdentitystoreClient
	Inspector                    services.InspectorClient
	Inspector2                   services.Inspector2Client
	Iot                          services.IotClient
	Kafka                        services.KafkaClient
	Kinesis                      services.KinesisClient
	Kms                          services.KmsClient
	Lambda                       services.LambdaClient
	Lightsail                    services.LightsailClient
	Mq                           services.MqClient
	Mwaa                         services.MwaaClient
	Neptune                      services.NeptuneClient
	Networkfirewall              services.NetworkfirewallClient
	Networkmanager               services.NetworkmanagerClient
	Organizations                services.OrganizationsClient
	Qldb                         services.QldbClient
	Quicksight                   services.QuicksightClient
	Ram                          services.RamClient
	Rds                          services.RdsClient
	Redshift                     services.RedshiftClient
	Resourcegroups               services.ResourcegroupsClient
	Resiliencehub                services.ResiliencehubClient
	Route53                      services.Route53Client
	Route53domains               services.Route53domainsClient
	Route53recoverycontrolconfig services.Route53recoverycontrolconfigClient
	Route53recoveryreadiness     services.Route53recoveryreadinessClient
	Route53resolver              services.Route53resolverClient
	S3                           services.S3Client
	S3control                    services.S3controlClient
	Sagemaker                    services.SagemakerClient
	Savingsplans                 services.SavingsplansClient
	Scheduler                    services.SchedulerClient
	Secretsmanager               services.SecretsmanagerClient
	Securityhub                  services.SecurityhubClient
	Servicecatalog               services.ServicecatalogClient
	Servicecatalogappregistry    services.ServicecatalogappregistryClient
	Servicediscovery             services.ServicediscoveryClient
	Servicequotas                services.ServicequotasClient
	Ses                          services.SesClient
	Sesv2                        services.Sesv2Client
	Sfn                          services.SfnClient
	Shield                       services.ShieldClient
	Signer                       services.SignerClient
	Sns                          services.SnsClient
	Sqs                          services.SqsClient
	Ssm                          services.SsmClient
	Ssoadmin                     services.SsoadminClient
	Support                      services.SupportClient
	Timestreamwrite              services.TimestreamwriteClient
	Transfer                     services.TransferClient
	Waf                          services.WafClient
	Wafregional                  services.WafregionalClient
	Wafv2                        services.Wafv2Client
	Wellarchitected              services.WellarchitectedClient
	Workspaces                   services.WorkspacesClient
	Xray                         services.XrayClient
}

func (*Services) Duplicate

func (s *Services) Duplicate() Services

func (*Services) GetService

func (s *Services) GetService(service AWSServiceName) any

func (*Services) InitService

func (s *Services) InitService(service AWSServiceName)

type ServicesManager

type ServicesManager struct {
	// contains filtered or unexported fields
}

ServicesManager will hold the entire map of (account X region) services

func (*ServicesManager) InitServices

func (s *ServicesManager) InitServices(details svcsDetail)

func (*ServicesManager) InitServicesForPartitionAccount

func (s *ServicesManager) InitServicesForPartitionAccount(partition, accountId string, svcs Services)

func (*ServicesManager) ServicesByPartitionAccount

func (s *ServicesManager) ServicesByPartitionAccount(partition, accountId string) *Services

type ServicesPartitionAccountMap

type ServicesPartitionAccountMap map[string]map[string]*Services

type SupportedServiceRegionsData

type SupportedServiceRegionsData struct {
	Partitions map[string]AwsPartition `json:"partitions"`
	// contains filtered or unexported fields
}

func ReadSupportedServiceRegions

func ReadSupportedServiceRegions() *SupportedServiceRegionsData

type TestOptions

type TestOptions struct {
	Region string

	SkipEmptyCheckColumns map[string][]string
}

Directories

Path Synopsis
When executed, this file modifies the mocks in the client/mocks directory and adds assertions to all of them to check that the Region parameter is being set in all calls to the AWS SDK.
When executed, this file modifies the mocks in the client/mocks directory and adds assertions to all of them to check that the Region parameter is being set in all calls to the AWS SDK.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Code generated by codegen; DO NOT EDIT.
Code generated by codegen; DO NOT EDIT.
gen

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL