awshelper

package
v0.69.9 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package awshelper provides helper functions for working with AWS services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssumeIamRole

func AssumeIamRole(iamRoleOpts options.IAMRoleOptions) (*sts.Credentials, error)

AssumeIamRole makes API calls to AWS to assume the IAM role specified and return the temporary AWS credentials to use that role.

func CreateAwsSession

func CreateAwsSession(config *AwsSessionConfig, terragruntOptions *options.TerragruntOptions) (*session.Session, error)

CreateAwsSession returns an AWS session object. The session is configured by either:

  • The provided AwsSessionConfig struct, which specifies region (required), profile name (optional), and IAM role to assume (optional).
  • The provided TerragruntOptions struct, which specifies any IAM role to assume (optional).

Note that if the AwsSessionConfig object is null, this will return default session credentials using the default credentials chain of the AWS SDK.

func CreateAwsSessionFromConfig

func CreateAwsSessionFromConfig(config *AwsSessionConfig, terragruntOptions *options.TerragruntOptions) (*session.Session, error)

CreateAwsSessionFromConfig returns an AWS session object for the given config region (required), profile name (optional), and IAM role to assume (optional), ensuring that the credentials are available.

func GetAWSAccountAlias added in v0.69.7

func GetAWSAccountAlias(config *AwsSessionConfig, terragruntOptions *options.TerragruntOptions) (string, error)

GetAWSAccountAlias gets the AWS account Alias of the current session configuration, if there is no alias an empty string is return.

func GetAWSAccountID

func GetAWSAccountID(config *AwsSessionConfig, terragruntOptions *options.TerragruntOptions) (string, error)

GetAWSAccountID gets the AWS account ID of the current session configuration.

func GetAWSCallerIdentity

func GetAWSCallerIdentity(config *AwsSessionConfig, terragruntOptions *options.TerragruntOptions) (sts.GetCallerIdentityOutput, error)

GetAWSCallerIdentity returns the AWS caller identity associated with the current set of credentials

func GetAWSIdentityArn

func GetAWSIdentityArn(config *AwsSessionConfig, terragruntOptions *options.TerragruntOptions) (string, error)

GetAWSIdentityArn gets the ARN of the AWS identity associated with the current set of credentials.

func GetAWSPartition

func GetAWSPartition(config *AwsSessionConfig, terragruntOptions *options.TerragruntOptions) (string, error)

GetAWSPartition gets the AWS Partition of the current session configuration

func GetAWSUserID

func GetAWSUserID(config *AwsSessionConfig, terragruntOptions *options.TerragruntOptions) (string, error)

GetAWSUserID gets the AWS user ID of the current session configuration.

func MarshalPolicy

func MarshalPolicy(policy Policy) ([]byte, error)

func ValidateAwsSession

func ValidateAwsSession(config *AwsSessionConfig, terragruntOptions *options.TerragruntOptions) error

ValidateAwsSession - Validate if current AWS session is valid

Types

type AwsSessionConfig

type AwsSessionConfig struct {
	Region                  string
	CustomS3Endpoint        string
	CustomDynamoDBEndpoint  string
	Profile                 string
	RoleArn                 string
	CredsFilename           string
	S3ForcePathStyle        bool
	DisableComputeChecksums bool
	ExternalID              string
	SessionName             string
}

AwsSessionConfig is a representation of the configuration options for an AWS Session

type Policy

type Policy struct {
	Version   string      `json:"Version"`
	Statement []Statement `json:"Statement"`
}

Policy - representation of the policy for AWS

func UnmarshalPolicy

func UnmarshalPolicy(policy string) (Policy, error)

type Statement

type Statement struct {
	Sid          string                  `json:"Sid"`
	Effect       string                  `json:"Effect"`
	Principal    interface{}             `json:"Principal,omitempty"`
	NotPrincipal interface{}             `json:"NotPrincipal,omitempty"`
	Action       interface{}             `json:"Action"`
	Resource     interface{}             `json:"Resource"`
	Condition    *map[string]interface{} `json:"Condition,omitempty"`
}

Statement - AWS policy statement Action and Resource - can be string OR array of strings https://docs.aws.amazon.com/IAM//latest/UserGuide/reference_policies_elements_action.html https://docs.aws.amazon.com/IAM//latest/UserGuide/reference_policies_elements_resource.html

Jump to

Keyboard shortcuts

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