func Must(sess *Session, err error) *Session {
	if err != nil {
		panic(err)
	}
	return sess
}
Must is a helper function to ensure the Session is valid and there was no
error when calling a NewSession function.

This helper is intended to be used in variable initialization to load the
Session and configuration at startup. Such as:

var sess = session.Must(session.NewSession())
package session
import (
	"crypto/tls"
	"crypto/x509"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"os"
	"time"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/awserr"
	"github.com/aws/aws-sdk-go/aws/client"
	"github.com/aws/aws-sdk-go/aws/corehandlers"
	"github.com/aws/aws-sdk-go/aws/credentials"
	"github.com/aws/aws-sdk-go/aws/csm"
	"github.com/aws/aws-sdk-go/aws/defaults"
	"github.com/aws/aws-sdk-go/aws/endpoints"
	"github.com/aws/aws-sdk-go/aws/request"
)
const (
	ErrCodeSharedConfig = "SharedConfigErr"
	ErrCodeLoadCustomCABundle = "LoadCustomCABundleError"
	ErrCodeLoadClientTLSCert = "LoadClientTLSCertError"
)
var ErrSharedConfigSourceCollision = awserr.New(ErrCodeSharedConfig, "only one credential type may be specified per profile: source profile, credential source, credential process, web identity token, or sso", nil)
var ErrSharedConfigECSContainerEnvVarEmpty = awserr.New(ErrCodeSharedConfig, "EcsContainer was specified as the credential_source, but 'AWS_CONTAINER_CREDENTIALS_RELATIVE_URI' was not set", nil)
var ErrSharedConfigInvalidCredSource = awserr.New(ErrCodeSharedConfig, "credential source values must be EcsContainer, Ec2InstanceMetadata, or Environment", nil)
type Session struct {
	Config   *aws.Config
	Handlers request.Handlers
	options Options
}
func New(cfgs ...*aws.Config) *Session {
	envCfg, envErr := loadEnvConfig()
	if envCfg.EnableSharedConfig {
		var cfg aws.Config
		cfg.MergeIn(cfgs...)
		s, err := NewSessionWithOptions(Options{
			Config:            cfg,
			SharedConfigState: SharedConfigEnable,
		})
		if err != nil {
			msg := "failed to create session with AWS_SDK_LOAD_CONFIG enabled. " +
				"Use session.NewSession to handle errors occurring during session creation."
			s = &Session{Config: defaults.Config()}
			s.logDeprecatedNewSessionError(msg, err, cfgs)
		}
		return s
	}
	s := deprecatedNewSession(envCfg, cfgs...)
	if envErr != nil {
		msg := "failed to load env config"
		s.logDeprecatedNewSessionError(msg, envErr, cfgs)
	}
	if csmCfg, err := loadCSMConfig(envCfg, []string{}); err != nil {
		if l := s.Config.Logger; l != nil {
			l.Log(fmt.Sprintf("ERROR: failed to load CSM configuration, %v", err))
		}
	} else if csmCfg.Enabled {
		err := enableCSM(&s.Handlers, csmCfg, s.Config.Logger)
		if err != nil {
			msg := "failed to enable CSM"
			s.logDeprecatedNewSessionError(msg, err, cfgs)
		}
	}
	return s
}
func NewSession(cfgs ...*aws.Config) (*Session, error) {
	opts := Options{}
	opts.Config.MergeIn(cfgs...)
	return NewSessionWithOptions(opts)
}
type SharedConfigState int
const (
	SharedConfigStateFromEnv SharedConfigState = iota
	SharedConfigDisable
	SharedConfigEnable
)
type Options struct {
	Config aws.Config
	Profile string
	SharedConfigState SharedConfigState
	SharedConfigFiles []string
	AssumeRoleTokenProvider func() (string, error)
	AssumeRoleDuration time.Duration
	CustomCABundle io.Reader
	ClientTLSCert io.Reader
	ClientTLSKey io.Reader
	Handlers request.Handlers
	EC2IMDSEndpoint string
}
func NewSessionWithOptions(opts Options) (*Session, error) {
	var envCfg envConfig
	var err error
	if opts.SharedConfigState == SharedConfigEnable {
		envCfg, err = loadSharedEnvConfig()
		if err != nil {
			return nil, fmt.Errorf("failed to load shared config, %v", err)
		}
	} else {
		envCfg, err = loadEnvConfig()
		if err != nil {
			return nil, fmt.Errorf("failed to load environment config, %v", err)
		}
	}
	if len(opts.Profile) != 0 {
		envCfg.Profile = opts.Profile
	}
	switch opts.SharedConfigState {
	case SharedConfigDisable:
		envCfg.EnableSharedConfig = false
	case SharedConfigEnable:
		envCfg.EnableSharedConfig = true
	}
	return newSession(opts, envCfg, &opts.Config)
}