client

package
v0.0.0-...-3c30a51 Latest Latest
Warning

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

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

Documentation

Index

Constants

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

Variables

View Source
var AllNamespaces = []string{
	"comprehend", "rds", "sagemaker", "appstream", "elasticmapreduce", "dynamodb", "lambda", "ecs", "cassandra", "ec2", "neptune", "kafka", "custom-resource", "elasticache",
}

Functions

func AccountMultiplex

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

func AwsMockTestHelper

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

func Configure

func Configure(ctx context.Context, logger zerolog.Logger, spec specs.Source, opts source.Options) (schema.ClientMeta, 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 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 ResolveObjectHash

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

func ResolveTagField

func ResolveTagField(fieldName 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(service string) func(meta schema.ClientMeta) []schema.ClientMeta

func ServiceAccountRegionNamespaceMultiplexer

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

func ServiceAccountRegionScopeMultiplexer

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

func ServiceAccountRegionsLanguageCodeMultiplex

func ServiceAccountRegionsLanguageCodeMultiplex(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 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

Types

type AWSService

type AWSService string
const (
	ApigatewayService           AWSService = "apigateway"
	Athena                      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"
	RedshiftService             AWSService = "redshift"
	Route53Service              AWSService = "route53"
	S3Service                   AWSService = "s3"
	SESService                  AWSService = "ses"
	WAFRegional                 AWSService = "waf-regional"
	WorkspacesService           AWSService = "workspaces"
	XRayService                 AWSService = "xray"
)

type Account

type Account struct {
	ID              string   `json:"id"`
	AccountName     string   `json:"account_name,omitempty"`
	LocalProfile    string   `json:"local_profile,omitempty"`
	RoleARN         string   `json:"role_arn,omitempty"`
	RoleSessionName string   `json:"role_session_name,omitempty"`
	ExternalID      string   `json:"external_id,omitempty"`
	DefaultRegion   string   `json:"default_region,omitempty"`
	Regions         []string `json:"regions,omitempty"`
	// contains filtered or unexported fields
}

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 AwsOrg

type AwsOrg struct {
	OrganizationUnits           []string `json:"organization_units,omitempty"`
	SkipMemberAccounts          []string `json:"skip_member_accounts,omitempty"`
	SkipOrganizationalUnits     []string `json:"skip_organization_units,omitempty"`
	AdminAccount                *Account `json:"admin_account"`
	MemberCredentials           *Account `json:"member_trusted_principal"`
	ChildAccountRoleName        string   `json:"member_role_name,omitempty"`
	ChildAccountRoleSessionName string   `json:"member_role_session_name,omitempty"`
	ChildAccountExternalID      string   `json:"member_external_id,omitempty"`
	ChildAccountRegions         []string `json:"member_regions,omitempty"`
}

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
	Backend              backend.Backend
	// contains filtered or unexported fields
}

func NewAwsClient

func NewAwsClient(logger zerolog.Logger, b backend.Backend) 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() *Services

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 {
	Accessanalyzer            services.AccessanalyzerClient
	Account                   services.AccountClient
	Acm                       services.AcmClient
	Amp                       services.AmpClient
	Amplify                   services.AmplifyClient
	Apigateway                services.ApigatewayClient
	Apigatewayv2              services.Apigatewayv2Client
	Applicationautoscaling    services.ApplicationautoscalingClient
	Apprunner                 services.ApprunnerClient
	Appstream                 services.AppstreamClient
	Appsync                   services.AppsyncClient
	Athena                    services.AthenaClient
	Autoscaling               services.AutoscalingClient
	Backup                    services.BackupClient
	Cloudformation            services.CloudformationClient
	Cloudfront                services.CloudfrontClient
	Cloudhsmv2                services.Cloudhsmv2Client
	Cloudtrail                services.CloudtrailClient
	Cloudwatch                services.CloudwatchClient
	Cloudwatchlogs            services.CloudwatchlogsClient
	Codebuild                 services.CodebuildClient
	Codepipeline              services.CodepipelineClient
	Cognitoidentity           services.CognitoidentityClient
	Cognitoidentityprovider   services.CognitoidentityproviderClient
	Configservice             services.ConfigserviceClient
	Databasemigrationservice  services.DatabasemigrationserviceClient
	Dax                       services.DaxClient
	Directconnect             services.DirectconnectClient
	Docdb                     services.DocdbClient
	Dynamodb                  services.DynamodbClient
	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
	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
	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
	Servicequotas             services.ServicequotasClient
	Ses                       services.SesClient
	Sesv2                     services.Sesv2Client
	Sfn                       services.SfnClient
	Shield                    services.ShieldClient
	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
	Workspaces                services.WorkspacesClient
	Xray                      services.XrayClient
	S3manager                 services.S3managerClient
}

type ServicesManager

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

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

func (*ServicesManager) InitServicesForPartitionAccountAndRegion

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

func (*ServicesManager) InitServicesForPartitionAccountAndScope

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

func (*ServicesManager) ServicesByAccountForWAFScope

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

func (*ServicesManager) ServicesByPartitionAccountAndRegion

func (s *ServicesManager) ServicesByPartitionAccountAndRegion(partition, accountId, region string) *Services

type ServicesPartitionAccountRegionMap

type ServicesPartitionAccountRegionMap map[string]map[string]map[string]*Services

type Spec

type Spec struct {
	Regions           []string  `json:"regions,omitempty"`
	Accounts          []Account `json:"accounts"`
	Organization      *AwsOrg   `json:"org"`
	AWSDebug          bool      `json:"aws_debug,omitempty"`
	MaxRetries        *int      `json:"max_retries,omitempty"`
	MaxBackoff        *int      `json:"max_backoff,omitempty"`
	EndpointURL       string    `json:"custom_endpoint_url,omitempty"`
	HostnameImmutable *bool     `json:"custom_endpoint_hostname_immutable,omitempty"`
	PartitionID       string    `json:"custom_endpoint_partition_id,omitempty"`
	SigningRegion     string    `json:"custom_endpoint_signing_region,omitempty"`
}

func (*Spec) Validate

func (s *Spec) Validate() error

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{}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
models
Code generated by codegen; DO NOT EDIT.
Code generated by codegen; DO NOT EDIT.

Jump to

Keyboard shortcuts

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