Skip to content

Instantly share code, notes, and snippets.

@joaoferrao
Created March 11, 2019 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joaoferrao/8d677df0ba39b5327e9598d1075039dd to your computer and use it in GitHub Desktop.
Save joaoferrao/8d677df0ba39b5327e9598d1075039dd to your computer and use it in GitHub Desktop.
caws_part_2
// GetServiceFromArn removes the arn:aws: component string of
// the name and returns the first keyword that appears, svc
func ServiceNameFromARN(arn *string) *string {
shortArn := strings.Replace(*arn, "arn:aws:", "", -1)
sliced := strings.Split(shortArn, ":")
return &sliced[0]
}
// Short ARN removes the unnecessary info from the ARN we already
// know at this point like region, account id and the service name.
func ShortArn(arn *string) string {
slicedArn := strings.Split(*arn, ":")
shortArn := slicedArn[5:] // the first 5 we already have
return strings.Join(shortArn, "/")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment