Documentation
¶
Overview ¶
Package awshelper provides helper functions for working with AWS services.
Index ¶
- func AssumeIamRole(iamRoleOpts options.IAMRoleOptions) (*sts.Credentials, error)
- func CreateAwsSession(config *AwsSessionConfig, opts *options.TerragruntOptions) (*session.Session, error)
- func CreateAwsSessionFromConfig(config *AwsSessionConfig, opts *options.TerragruntOptions) (*session.Session, error)
- func CreateS3Client(config *AwsSessionConfig, opts *options.TerragruntOptions) (*s3.S3, error)
- func GetAWSAccountAlias(sess *session.Session) (string, error)
- func GetAWSAccountID(sess *session.Session) (string, error)
- func GetAWSCallerIdentity(sess *session.Session) (sts.GetCallerIdentityOutput, error)
- func GetAWSIdentityArn(sess *session.Session) (string, error)
- func GetAWSPartition(sess *session.Session) (string, error)
- func GetAWSUserID(sess *session.Session) (string, error)
- func MarshalPolicy(policy Policy) ([]byte, error)
- func ValidateAwsSession(sess *session.Session) error
- func ValidatePublicAccessBlock(output *s3.GetPublicAccessBlockOutput) (bool, error)
- type AwsSessionConfig
- type Policy
- type Statement
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, opts *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, opts *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 CreateS3Client ¶ added in v0.77.0
func CreateS3Client(config *AwsSessionConfig, opts *options.TerragruntOptions) (*s3.S3, error)
func GetAWSAccountAlias ¶ added in v0.69.7
GetAWSAccountAlias gets the AWS account Alias of the current session configuration, if there is no alias an empty string is return.
func GetAWSAccountID ¶
GetAWSAccountID gets the AWS account ID of the current session configuration.
func GetAWSCallerIdentity ¶
func GetAWSCallerIdentity(sess *session.Session) (sts.GetCallerIdentityOutput, error)
GetAWSCallerIdentity returns the AWS caller identity associated with the current set of credentials
func GetAWSIdentityArn ¶
GetAWSIdentityArn gets the ARN of the AWS identity associated with the current set of credentials.
func GetAWSPartition ¶
GetAWSPartition gets the AWS Partition of the current session configuration
func GetAWSUserID ¶
GetAWSUserID gets the AWS user ID of the current session configuration.
func MarshalPolicy ¶
func ValidateAwsSession ¶
ValidateAwsSession - Validate if current AWS session is valid
func ValidatePublicAccessBlock ¶ added in v0.77.0
func ValidatePublicAccessBlock(output *s3.GetPublicAccessBlockOutput) (bool, error)
Types ¶
type AwsSessionConfig ¶
type AwsSessionConfig struct {
Tags map[string]string
Region string
CustomS3Endpoint string
CustomDynamoDBEndpoint string
Profile string
RoleArn string
CredsFilename string
ExternalID string
SessionName string
S3ForcePathStyle bool
DisableComputeChecksums bool
}
AwsSessionConfig is a representation of the configuration options for an AWS Session
type Statement ¶
type Statement struct {
Principal any `json:"Principal,omitempty"`
NotPrincipal any `json:"NotPrincipal,omitempty"`
Action any `json:"Action"`
Resource any `json:"Resource"`
Condition *map[string]any `json:"Condition,omitempty"`
Sid string `json:"Sid"`
Effect string `json:"Effect"`
}
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