iamx

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 License: BSD-3-Clause Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Invalid         = Entity("")
	Group           = Entity("AGPA")
	InstanceProfile = Entity("AIPA")
	ManagedPolicy   = Entity("ANPA")
	PolicyVersion   = Entity("ANVA")
	Role            = Entity("AROA")
	Root            = Entity("A3T")
	ServerCert      = Entity("ASCA")
	TempKey         = Entity("ASIA")
	User            = Entity("AIDA")
	UserKey         = Entity("AKIA")
)

IAM entity ID prefixes (https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-prefixes).

View Source
const (
	Allow = Effect("Allow")
	Deny  = Effect("Deny")
)

Effect values.

View Source
const PolicyVersion2012 = "2012-10-17"

PolicyVersion2012 is the IAM policy version supported by iamx package.

Variables

This section is empty.

Functions

func Is

func Is(id string, typ Entity) bool

Is returns true if id belongs to the specified entity type.

func ManagedPolicyARN

func ManagedPolicyARN(partition, resource string) arn.ARN

ManagedPolicyARN returns the ARN of a managed IAM policy. Partition defaults to aws, if not specified. An empty ARN is returned if resource is empty. Job functions may be specified without a path, but it is required for other managed policies. If resource is already an ARN, it is returned with an updated partition.

Types

type Client

type Client struct{ iam.IAM }

Client is an extended IAM client with additional methods for managing users and roles.

func New

func New(cfg *aws.Config) Client

New returns a new extended IAM client.

func (Client) DeleteRole

func (c Client) DeleteRole(role string) error

DeleteRole deletes the specified role, ensuring that all prerequisites for deletion are met.

func (Client) DeleteRoles

func (c Client) DeleteRoles(path string) error

DeleteRoles deletes all roles under the specified IAM path.

func (Client) DeleteUser

func (c Client) DeleteUser(name string) error

DeleteUser deletes the specified user, ensuring that all prerequisites for deletion are met.

func (Client) DeleteUsers

func (c Client) DeleteUsers(path string) error

DeleteUsers deletes all users under the specified IAM path.

func (Client) GobDecode

func (Client) GobDecode([]byte) error

GobDecode prevents the client from being decoded by gob.

func (Client) GobEncode

func (Client) GobEncode() ([]byte, error)

GobEncode prevents the client from being encoded by gob.

type ConditionMap

type ConditionMap map[string]Conditions

ConditionMap associates policy condition type with a set of conditions.

type Conditions

type Conditions map[string]PolicyMultiVal

Conditions contains one or more policy conditions of the same type.

type Effect

type Effect string

Effect is the statement allow/deny effect.

type Entity

type Entity string

Entity identifies IAM entity type by its ID prefix.

func Type

func Type(id string) (e Entity)

Type identifies entity type by its ID prefix.

type Policy

type Policy struct {
	Version   string `json:",omitempty"`
	ID        string `json:"Id,omitempty"`
	Statement []*Statement
}

Policy is an IAM policy document.

func AssumeRolePolicy

func AssumeRolePolicy(e Effect, principals ...string) *Policy

AssumeRolePolicy returns an AssumeRole policy document.

func ParsePolicy

func ParsePolicy(s *string) (*Policy, error)

ParsePolicy decodes an IAM policy document.

func (*Policy) Doc

func (p *Policy) Doc() *string

Doc returns JSON representation of policy p.

type PolicyMultiVal

type PolicyMultiVal []string

PolicyMultiVal is a JSON type that may be encoded either as a string or an array, depending on the number of entries.

func (PolicyMultiVal) Equal

func (v PolicyMultiVal) Equal(o PolicyMultiVal) bool

Equal returns true if both policy values contain the same entries in the same order.

func (PolicyMultiVal) MarshalJSON

func (v PolicyMultiVal) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*PolicyMultiVal) UnmarshalJSON

func (v *PolicyMultiVal) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

type Principal

type Principal struct {
	PrincipalMap
	Any bool
}

Principal specifies the entity to which a statement applies.

func NewAWSPrincipal

func NewAWSPrincipal(ids ...string) *Principal

NewAWSPrincipal returns a new Principal containing the specified AWS ids.

func (*Principal) MarshalJSON

func (p *Principal) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Principal) UnmarshalJSON

func (p *Principal) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

type PrincipalMap

type PrincipalMap struct {
	AWS       PolicyMultiVal `json:",omitempty"`
	Federated PolicyMultiVal `json:",omitempty"`
	Service   PolicyMultiVal `json:",omitempty"`
}

PrincipalMap is a non-wildcard principal value.

type Statement

type Statement struct {
	SID          string         `json:"Sid,omitempty"`
	Effect       Effect         `json:""`
	Principal    *Principal     `json:",omitempty"`
	NotPrincipal *Principal     `json:",omitempty"`
	Action       PolicyMultiVal `json:",omitempty"`
	NotAction    PolicyMultiVal `json:",omitempty"`
	Resource     PolicyMultiVal `json:",omitempty"`
	NotResource  PolicyMultiVal `json:",omitempty"`
	Condition    ConditionMap   `json:",omitempty"`
}

Statement is an IAM policy statement.

Jump to

Keyboard shortcuts

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