MCPcopy Create free account
hub / github.com/dan-v/lambda-nat-proxy / NewClientFactory

Function NewClientFactory

internal/aws/clients.go:85–119  ·  view source on GitHub ↗

NewClientFactory creates a new AWS client factory

(cfg *config.CLIConfig)

Source from the content-addressed store, hash-verified

83
84// NewClientFactory creates a new AWS client factory
85func NewClientFactory(cfg *config.CLIConfig) (*ClientFactory, error) {
86 awsConfig := &aws.Config{
87 Region: aws.String(cfg.AWS.Region),
88 }
89
90 // Add retry configuration
91 awsConfig.Retryer = client.DefaultRetryer{
92 NumMaxRetries: 5,
93 MinRetryDelay: 100 * time.Millisecond,
94 MinThrottleDelay: 500 * time.Millisecond,
95 MaxRetryDelay: 5 * time.Second,
96 MaxThrottleDelay: 30 * time.Second,
97 }
98
99 // Set profile if specified
100 sessionOpts := session.Options{
101 Config: *awsConfig,
102 SharedConfigState: session.SharedConfigEnable,
103 }
104
105 if cfg.AWS.Profile != "" {
106 sessionOpts.Profile = cfg.AWS.Profile
107 }
108
109 sess, err := session.NewSessionWithOptions(sessionOpts)
110 if err != nil {
111 return nil, fmt.Errorf("failed to create AWS session: %w", err)
112 }
113
114 factory := &ClientFactory{
115 session: sess,
116 }
117
118 return factory, nil
119}
120
121// GetClients returns all AWS service clients
122func (f *ClientFactory) GetClients() *Clients {

Callers 3

TestNewClientFactoryFunction · 0.85
TestGetClientsFunction · 0.85
TestGetRegionFunction · 0.85

Calls

no outgoing calls

Tested by 3

TestNewClientFactoryFunction · 0.68
TestGetClientsFunction · 0.68
TestGetRegionFunction · 0.68