iam

package
v0.0.0-...-d1ede0d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2019 License: BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ARNRegexp = regexp.MustCompile(`^arn:(\w|-)*:iam::\d+:role\/?(\w+|-|\/|\.)*$`)

ARNRegexp is the regex to check that the base ARN is valid, see http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-arns.

Functions

func GetBaseArn

func GetBaseArn() (string, error)

GetBaseArn get the base ARN from metadata service.

func GetEndpointFromRegion

func GetEndpointFromRegion(region string) string

GetEndpointFromRegion formas a standard sts endpoint url given a region

func GetInstanceIAMRole

func GetInstanceIAMRole() (string, error)

GetInstanceIAMRole get instance IAM role from metadata service.

func IsValidBaseARN

func IsValidBaseARN(arn string) bool

IsValidBaseARN validates that the base ARN is valid.

func IsValidRegion

func IsValidRegion(promisedLand string) bool

IsValidRegion tests for a vaild region name

Types

type Client

type Client struct {
	BaseARN             string
	Endpoint            string
	UseRegionalEndpoint bool
}

Client represents an IAM client.

func NewClient

func NewClient(baseARN string, regional bool) *Client

NewClient returns a new IAM client.

func (*Client) AssumeRole

func (iam *Client) AssumeRole(roleARN, remoteIP string, sessionTTL time.Duration) (*Credentials, error)

AssumeRole returns an IAM role Credentials using AWS STS.

func (*Client) EndpointFor

func (iam *Client) EndpointFor(service, region string, optFns ...func(*endpoints.Options)) (endpoints.ResolvedEndpoint, error)

EndpointFor implements the endpoints.Resolver interface for use with sts

func (*Client) RoleARN

func (iam *Client) RoleARN(role string) string

RoleARN returns the full iam role ARN.

type Credentials

type Credentials struct {
	AccessKeyID     string `json:"AccessKeyId"`
	Code            string
	Expiration      string
	LastUpdated     string
	SecretAccessKey string
	Token           string
	Type            string
}

Credentials represent the security Credentials response.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL