agent/ec2/ec2_metadata_client.go
func (c *ec2MetadataClientImpl) DefaultCredentials() (*RoleCredentials, error) {
	securityCredential, err := c.client.GetMetadata(SecurityCrednetialsResource)
	if err != nil {
		return nil, err
	}

	securityCredentialList := strings.Split(strings.TrimSpace(securityCredential), "\n")
	if len(securityCredentialList) == 0 {
		return nil, errors.New("No security credentials in response")
	}

	defaultCredentialName := securityCredentialList[0]

	defaultCredentialStr, err := c.client.GetMetadata(SecurityCrednetialsResource + defaultCredentialName)
	if err != nil {
		return nil, err
	}
	var credential RoleCredentials
	err = json.Unmarshal([]byte(defaultCredentialStr), &credential)
	if err != nil {
		return nil, err
	}
	return &credential, nil
}
func (c *ec2MetadataClientImpl) DefaultCredentials() (*RoleCredentials, error) {
	securityCredential, err := c.client.GetMetadata(SecurityCrednetialsResource)
	if err != nil {
		return nil, err
	}

	securityCredentialList := strings.Split(strings.TrimSpace(securityCredential), "\n")
	if len(securityCredentialList) == 0 {
		return nil, errors.New("No security credentials in response")
	}

	defaultCredentialName := securityCredentialList[0]

	defaultCredentialStr, err := c.client.GetMetadata(SecurityCrednetialsResource + defaultCredentialName)
	if err != nil {
		return nil, err
	}
	var credential RoleCredentials
	err = json.Unmarshal([]byte(defaultCredentialStr), &credential)
	if err != nil {
		return nil, err
	}
	return &credential, nil
}
func ( c * ec2MetadataClientImpl ) DefaultCredentials ( ) ( * RoleCredentials , error ) { securityCredential , err := c . client . GetMetadata ( SecurityCrednetialsResource ) if err != nil { return nil , err } securityCredentialList := strings . Split ( strings . TrimSpace ( securityCredential ) , " \n " ) if len ( securityCredentialList ) == 0 { return nil , errors . New ( " " ) } defaultCredentialName := securityCredentialList [ 0 ] defaultCredentialStr , err := c . client . GetMetadata ( SecurityCrednetialsResource + defaultCredentialName ) if err != nil { return nil , err } var credential RoleCredentials err = json . Unmarshal ( [ ] byte ( defaultCredentialStr ) , & credential ) if err != nil { return nil , err } return & credential , nil }
// DefaultCredentials returns the credentials associated with the instance iam role
DefaultCredentials returns the credentials associated with the instance iam role