func()

in internal/plugin/plugin.go [91:127]


func (c *OperationConfig) awsConfig(ctx context.Context) (aws.Config, error) {
	var opts []func(*config.LoadOptions) error

	opts = append(opts, config.WithAPIOptions([]func(*smithyMW.Stack) error{
		middleware.AddUserAgentKeyValue("lightsailctl", internal.Version.String()),
	}))

	if c.Region != "" {
		opts = append(opts, config.WithRegion(c.Region))
	}

	if c.Profile != "" {
		opts = append(opts, config.WithSharedConfigProfile(c.Profile))
	}

	if c.Debug {
		opts = append(opts, config.WithClientLogMode(aws.LogSigning|aws.LogRequestWithBody|aws.LogResponseWithBody))
	}

	if c.DoNotVerifySSL {
		opts = append(opts, config.WithHTTPClient(&http.Client{
			Transport: &http.Transport{
				TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
			},
		}))
	}

	if c.CABundle != "" {
		b, err := os.ReadFile(c.CABundle)
		if err != nil {
			return aws.Config{}, fmt.Errorf("read CA bundle file: %w", err)
		}
		opts = append(opts, config.WithCustomCABundle(bytes.NewReader(b)))
	}

	return config.LoadDefaultConfig(ctx, opts...)
}