iam

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package iam contains helpers to interact with IAM objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Policy

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

Policy mirrors the structure of an IAM Policy for easy marshaling and unmarshaling to/from JSON. See https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#access_policies-json

func NewPolicy

func NewPolicy(stmts ...PolicyStatement) Policy

NewPolicy returns a new Policy with the given Statements applied to it.

type PolicyStatement

type PolicyStatement struct {
	Sid       string                   `json:"Sid,omitempty"`
	Effect    PolicyStatementEffect    `json:"Effect"`
	Principal PolicyStatementPrincipal `json:"Principal,omitempty"`
	Action    []string                 `json:"Action"`
	Resource  []string                 `json:"Resource"`
	Condition PolicyStatementCondition `json:"Condition,omitempty"`
}

PolicyStatement is a Statement element in a Policy.

func NewPolicyStatement

func NewPolicyStatement(effect PolicyStatementEffect, opts ...PolicyStatementOpt) PolicyStatement

NewPolicyStatement returns a new PolicyStatement with the given options applied to it.

type PolicyStatementCondition

type PolicyStatementCondition struct {
	ArnEquals    map[string]string `json:"ArnEquals,omitempty"`
	StringEquals map[string]string `json:"StringEquals,omitempty"`
}

PolicyStatementCondition is the Condition element of a Statement. See https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html

type PolicyStatementEffect

type PolicyStatementEffect string

PolicyStatementEffect represents the Effect element of a Statement.

const (
	EffectAllow PolicyStatementEffect = "Allow"
)

List of acceptable PolicyStatementEffect values.

type PolicyStatementOpt

type PolicyStatementOpt func(*PolicyStatement)

PolicyStatementOpt is a functional option for a PolicyStatement.

func Action

func Action(action string) PolicyStatementOpt

Action adds an Action.

func ConditionArnEquals

func ConditionArnEquals(key, val string) PolicyStatementOpt

ConditionArnEquals sets a Condition of type "ArnEquals".

func ConditionStringEquals

func ConditionStringEquals(key, val string) PolicyStatementOpt

ConditionStringEquals sets a Condition of type "StringEquals".

func PrincipalService

func PrincipalService(service string) PolicyStatementOpt

PrincipalService adds a "Service" to the Principal.

func Resource

func Resource(resource string) PolicyStatementOpt

Resource adds a Resource.

type PolicyStatementPrincipal

type PolicyStatementPrincipal struct {
	Service []string `json:"Service"`
}

PolicyStatementPrincipal is the Principal element of a Statement. https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html

Jump to

Keyboard shortcuts

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