18
18
log = logrus .New ()
19
19
)
20
20
21
- // Helper function to validate ARNs
21
+ // ValidateARN is a helper function to validate ARNs
22
22
func ValidateARN (arnString string ) bool {
23
23
_ , err := arn .Parse (arnString )
24
24
if err != nil {
@@ -28,7 +28,7 @@ func ValidateARN(arnString string) bool {
28
28
return true
29
29
}
30
30
31
- // Helper function to get region from ARNs
31
+ // GetRegionFromARN is a helper function to get region from ARNs
32
32
func GetRegionFromARN (arnString string ) string {
33
33
arn , err := arn .Parse (arnString )
34
34
if err != nil {
@@ -54,7 +54,7 @@ func InstanceProfileArn(svc *ec2metadata.EC2Metadata) (arn.ARN, error) {
54
54
return arn .Parse (info .InstanceProfileArn )
55
55
}
56
56
57
- // BaseArn calculates the base SNS arn given an instance's arn
57
+ // BaseSNSArn calculates the base SNS arn given an instance's arn
58
58
func BaseSNSArn (instanceProfileArn arn.ARN , region string ) (string , error ) {
59
59
// instance profile arn will be of the form:
60
60
// arn:aws:iam::account-id:instance-profile/role-name
@@ -81,22 +81,22 @@ func DetectARNPrefix(sess *session.Session) (string, error) {
81
81
return "" , err
82
82
}
83
83
84
- region , err := svc .Region ()
84
+ region , _ := svc .Region ()
85
85
if region == "" || ! ValidateRegionString (region ) {
86
86
// Could not get region, will try to get it from env
87
87
if os .Getenv ("AWS_REGION" ) != "" && ValidateRegionString (os .Getenv ("AWS_REGION" )) {
88
88
region = os .Getenv ("AWS_REGION" )
89
89
} else if os .Getenv ("AWS_DEFAULT_REGION" ) != "" && ValidateRegionString (os .Getenv ("AWS_DEFAULT_REGION" )) {
90
90
region = os .Getenv ("AWS_DEFAULT_REGION" )
91
91
} else {
92
- return "" , errors .New ("The ARN prefix was not supplied and could not be detected. " )
92
+ return "" , errors .New ("The ARN prefix was not supplied and could not be detected" )
93
93
}
94
94
}
95
95
96
96
return BaseSNSArn (instanceArn , region )
97
97
}
98
98
99
- // Helper function to validate the region string
99
+ // ValidateRegionString is a helper function to validate the region string
100
100
func ValidateRegionString (region string ) bool {
101
101
_ , exists := endpoints .PartitionForRegion (endpoints .DefaultPartitions (), region )
102
102
return exists
0 commit comments