NewArnFromString parses string representation of ARN into Arn object. Returns an error if the string format is incorrect.
(arn string)
| 120 | // NewArnFromString parses string representation of ARN into Arn object. |
| 121 | // Returns an error if the string format is incorrect. |
| 122 | func NewArnFromString(arn string) (Arn, error) { |
| 123 | parts := strings.Split(arn, ":") |
| 124 | if len(parts) != 6 { |
| 125 | return Arn{}, ErrInvalidArnFormat |
| 126 | } |
| 127 | if parts[0] != "arn" { |
| 128 | return Arn{}, ErrInvalidArnPrefix |
| 129 | } |
| 130 | |
| 131 | return NewArn(parts[1], parts[2], parts[3], parts[4], parts[5]), nil |
| 132 | } |
| 133 | |
| 134 | // String returns the string format of the ARN |
| 135 | func (arn Arn) String() string { |