// getEC2MetadataClient creates a new instance of the EC2Metadata client func (cfg *CliConfig) getEC2MetadataClient(awsDefaults *defaults.Defaults) *ec2metadata.EC2Metadata { opts := func(opts *endpoints.Options) { opts.DisableSSL = true opts.UseDualStack = false } endpoint, _ := endpoints.DefaultResolver().EndpointFor(ec2metadata.ServiceName, cfg.getRegion(), opts) return ec2metadata.NewClient(*awsDefaults.Config, awsDefaults.Handlers, endpoint.URL, endpoint.SigningRegion) }
func ec2RoleProvider(cfg aws.Config, handlers request.Handlers) credentials.Provider { endpoint, signingRegion := endpoints.EndpointForRegion(ec2metadata.ServiceName, aws.StringValue(cfg.Region), true, false) return &ec2rolecreds.EC2RoleProvider{ Client: ec2metadata.NewClient(cfg, handlers, endpoint, signingRegion), ExpiryWindow: 5 * time.Minute, } }
func ec2RoleProvider(cfg aws.Config, handlers request.Handlers) credentials.Provider { resolver := cfg.EndpointResolver if resolver == nil { resolver = endpoints.DefaultResolver() } e, _ := resolver.EndpointFor(endpoints.Ec2metadataServiceID, "") return &ec2rolecreds.EC2RoleProvider{ Client: ec2metadata.NewClient(cfg, handlers, e.URL, e.SigningRegion), ExpiryWindow: 5 * time.Minute, } }
// CredChain returns the default credential chain. // // Generally you shouldn't need to use this method directly, but // is available if you need to reset the credentials of an // existing service client or session's Config. func CredChain(cfg *aws.Config, handlers request.Handlers) *credentials.Credentials { endpoint, signingRegion := endpoints.EndpointForRegion(ec2metadata.ServiceName, *cfg.Region, true) return credentials.NewChainCredentials( []credentials.Provider{ &credentials.EnvProvider{}, &credentials.SharedCredentialsProvider{Filename: "", Profile: ""}, &ec2rolecreds.EC2RoleProvider{ Client: ec2metadata.NewClient(*cfg, handlers, endpoint, signingRegion), ExpiryWindow: 5 * time.Minute, }, }) }
// getEC2MetadataClient creates a new instance of the EC2Metadata client func (cfg *CliConfig) getEC2MetadataClient(awsDefaults *defaults.Defaults) *ec2metadata.EC2Metadata { endpoint, signingRegion := endpoints.EndpointForRegion(ec2metadata.ServiceName, cfg.getRegion(), true, false) return ec2metadata.NewClient(*awsDefaults.Config, awsDefaults.Handlers, endpoint, signingRegion) }