Exemplo n.º 1
0
func GetKeys(user string, svc *iam.IAM) ([]string, error) {
	resp, err := svc.ListSSHPublicKeys(&iam.ListSSHPublicKeysInput{
		UserName: aws.String(user),
	})
	if err != nil {
		log.Error(fmt.Sprintf("Error getting keys for user %v", user))
		return nil, err
	}
	if len(resp.SSHPublicKeys) > 0 {
		ukey, err := getUserKey(user, svc, resp.SSHPublicKeys)
		if err != nil {
			log.Error("Error calling getUserKey")
			return nil, err
		} else {
			return ukey, nil
		}
	}
	return nil, nil
}