Skip to content

Commit

Permalink
Merge pull request #1169 from remind101/arn-change-workaround
Browse files Browse the repository at this point in the history
Workaround new long ARNs
  • Loading branch information
aengelas committed Mar 16, 2021
2 parents 3c5a5ca + 559d068 commit 30eb747
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/arn/arn.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (a *ARN) String() string {
// SplitResource splits the Resource section of an ARN into its type and id
// components.
func SplitResource(r string) (resource, id string, err error) {
p := strings.Split(r, "/")
p := strings.SplitN(r, "/", 2)

if len(p) != 2 {
err = ErrInvalidResource
Expand Down
9 changes: 9 additions & 0 deletions pkg/arn/arn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ func TestParse(t *testing.T) {
Account: "249285743859",
Resource: "service/acme-inc:web",
}},
{"arn:aws:ecs:us-east-1:249285743859:service/my-cluster/acme-inc:web", ARN{
ARN: "arn",
AWS: "aws",
Service: "ecs",
Region: "us-east-1",
Account: "249285743859",
Resource: "service/my-cluster/acme-inc:web",
}},
}

for i, tt := range tests {
Expand All @@ -41,6 +49,7 @@ func TestSplitResource(t *testing.T) {
err error
}{
{"service/acme-inc", "service", "acme-inc", nil},
{"service/my-cluster-name/acme-inc", "service", "my-cluster-name/acme-inc", nil},
{"service", "", "", ErrInvalidResource},
}

Expand Down

0 comments on commit 30eb747

Please sign in to comment.