NewClientFactory creates a new AWS client factory
(cfg *config.CLIConfig)
| 83 | |
| 84 | // NewClientFactory creates a new AWS client factory |
| 85 | func 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 |
| 122 | func (f *ClientFactory) GetClients() *Clients { |
no outgoing calls