-
Notifications
You must be signed in to change notification settings - Fork 4
Fix IAM Role ARN if trying to run against GovCloud #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cmd/main.go
Outdated
if partition, ok := endpoints.PartitionForRegion(endpoints.DefaultPartitions(), region); ok { | ||
return partition.ID() | ||
} | ||
return "aws" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not always return partition.ID? Won't this always be either "aws" or "aws-gov"? If it errors out, isn't that a bad sign? I suspect this is a "Chas doesn't understand Go" problem, but I'm curious nevertheless.
cmd/main.go
Outdated
func getPartition(region string) string { | ||
if partition, ok := endpoints.PartitionForRegion(endpoints.DefaultPartitions(), region); ok { | ||
return partition.ID() | ||
} | ||
return "aws" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func getPartition(region string) string { | |
if partition, ok := endpoints.PartitionForRegion(endpoints.DefaultPartitions(), region); ok { | |
return partition.ID() | |
} | |
return "aws" | |
} | |
func getPartition(region string) (string, error) { | |
partition, ok := endpoints.PartitionForRegion(endpoints.DefaultPartitions(), region) | |
if !ok { | |
return "", fmt.Errorf("Error finding partition for region: %s", region) | |
} | |
return partition.ID(), nil | |
} |
cmd/main.go
Outdated
RoleARN: fmt.Sprintf("arn:aws:iam::%v:role/%v", | ||
options.AwsAccountID, options.Role), | ||
RoleARN: fmt.Sprintf("arn:%s:iam::%d:role/%s", | ||
getPartition(options.AwsRegion), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getPartition(options.AwsRegion), | |
partition, |
Then add above something to call getPartition
like:
partition, err := getPartition(options.AwsRegion)
if err != nil {
fmt.Println(err)
fmt.Println("Using aws as partition")
partition = "aws"
}
If you want to avoid noping out of the process
Up til now we've been hardcoding the AWS partition, which breaks when trying to run against GovCloud. This PR looks up the AWS partition based on the region you're passing in.
Tested by running