1
- package aws_helper
1
+ // Package awshelper provides helper functions for working with AWS services.
2
+ package awshelper
2
3
3
4
import (
4
5
"fmt"
@@ -20,7 +21,7 @@ import (
20
21
"github.com/gruntwork-io/terragrunt/options"
21
22
)
22
23
23
- // A representation of the configuration options for an AWS Session
24
+ // AwsSessionConfig is a representation of the configuration options for an AWS Session
24
25
type AwsSessionConfig struct {
25
26
Region string
26
27
CustomS3Endpoint string
@@ -41,7 +42,7 @@ var addUserAgent = request.NamedHandler{
41
42
"terragrunt" , version .GetVersion ()),
42
43
}
43
44
44
- // Returns an AWS session object for the given config region (required), profile name (optional), and IAM role to assume
45
+ // CreateAwsSessionFromConfig returns an AWS session object for the given config region (required), profile name (optional), and IAM role to assume
45
46
// (optional), ensuring that the credentials are available.
46
47
func CreateAwsSessionFromConfig (config * AwsSessionConfig , terragruntOptions * options.TerragruntOptions ) (* session.Session , error ) {
47
48
defaultResolver := endpoints .DefaultResolver ()
@@ -185,7 +186,7 @@ func getCredentialsFromEnvs(opts *options.TerragruntOptions) *credentials.Creden
185
186
return credentials .NewStaticCredentials (accessKeyID , secretAccessKey , sessionToken )
186
187
}
187
188
188
- // Returns an AWS session object. The session is configured by either:
189
+ // CreateAwsSession returns an AWS session object. The session is configured by either:
189
190
// - The provided AwsSessionConfig struct, which specifies region (required), profile name (optional), and IAM role to
190
191
// assume (optional).
191
192
// - The provided TerragruntOptions struct, which specifies any IAM role to assume (optional).
@@ -238,7 +239,7 @@ func CreateAwsSession(config *AwsSessionConfig, terragruntOptions *options.Terra
238
239
return sess , nil
239
240
}
240
241
241
- // Make API calls to AWS to assume the IAM role specified and return the temporary AWS credentials to use that role
242
+ // AssumeIamRole makes API calls to AWS to assume the IAM role specified and return the temporary AWS credentials to use that role.
242
243
func AssumeIamRole (iamRoleOpts options.IAMRoleOptions ) (* sts.Credentials , error ) {
243
244
sessionOptions := session.Options {SharedConfigState : session .SharedConfigEnable }
244
245
@@ -318,7 +319,7 @@ func AssumeIamRole(iamRoleOpts options.IAMRoleOptions) (*sts.Credentials, error)
318
319
return resp .Credentials , nil
319
320
}
320
321
321
- // Return the AWS caller identity associated with the current set of credentials
322
+ // GetAWSCallerIdentity returns the AWS caller identity associated with the current set of credentials
322
323
func GetAWSCallerIdentity (config * AwsSessionConfig , terragruntOptions * options.TerragruntOptions ) (sts.GetCallerIdentityOutput , error ) {
323
324
sess , err := CreateAwsSession (config , terragruntOptions )
324
325
if err != nil {
@@ -340,7 +341,7 @@ func ValidateAwsSession(config *AwsSessionConfig, terragruntOptions *options.Ter
340
341
return err
341
342
}
342
343
343
- // Get the AWS Partition of the current session configuration
344
+ // GetAWSPartition gets the AWS Partition of the current session configuration
344
345
func GetAWSPartition (config * AwsSessionConfig , terragruntOptions * options.TerragruntOptions ) (string , error ) {
345
346
identity , err := GetAWSCallerIdentity (config , terragruntOptions )
346
347
if err != nil {
@@ -355,7 +356,7 @@ func GetAWSPartition(config *AwsSessionConfig, terragruntOptions *options.Terrag
355
356
return arn .Partition , nil
356
357
}
357
358
358
- // Get the AWS account ID of the current session configuration
359
+ // GetAWSAccountID gets the AWS account ID of the current session configuration.
359
360
func GetAWSAccountID (config * AwsSessionConfig , terragruntOptions * options.TerragruntOptions ) (string , error ) {
360
361
identity , err := GetAWSCallerIdentity (config , terragruntOptions )
361
362
if err != nil {
@@ -365,7 +366,7 @@ func GetAWSAccountID(config *AwsSessionConfig, terragruntOptions *options.Terrag
365
366
return * identity .Account , nil
366
367
}
367
368
368
- // Get the ARN of the AWS identity associated with the current set of credentials
369
+ // GetAWSIdentityArn gets the ARN of the AWS identity associated with the current set of credentials.
369
370
func GetAWSIdentityArn (config * AwsSessionConfig , terragruntOptions * options.TerragruntOptions ) (string , error ) {
370
371
identity , err := GetAWSCallerIdentity (config , terragruntOptions )
371
372
if err != nil {
@@ -375,7 +376,7 @@ func GetAWSIdentityArn(config *AwsSessionConfig, terragruntOptions *options.Terr
375
376
return * identity .Arn , nil
376
377
}
377
378
378
- // Get the AWS user ID of the current session configuration
379
+ // GetAWSUserID gets the AWS user ID of the current session configuration.
379
380
func GetAWSUserID (config * AwsSessionConfig , terragruntOptions * options.TerragruntOptions ) (string , error ) {
380
381
identity , err := GetAWSCallerIdentity (config , terragruntOptions )
381
382
if err != nil {
0 commit comments