-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
d/aws_cloudwatch_log_groups: Remove trailing ':*' from ARNs.
- Loading branch information
Showing
6 changed files
with
111 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package cloudwatchlogs | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
const ( | ||
logGroupARNWildcardSuffix = ":*" | ||
) | ||
|
||
// TrimLogGroupARNWildcardSuffix trims any wilcard suffix from a Log Group ARN. | ||
func TrimLogGroupARNWildcardSuffix(arn string) string { | ||
return strings.TrimSuffix(arn, logGroupARNWildcardSuffix) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cloudwatchlogs_test | ||
|
||
import ( | ||
"testing" | ||
|
||
tfcloudwatchlogs "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/cloudwatchlogs" | ||
) | ||
|
||
func TestTrimLogGroupARNWildcardSuffix(t *testing.T) { | ||
testCases := []struct { | ||
TestName string | ||
InputARN string | ||
ExpectedARN string | ||
}{ | ||
{ | ||
TestName: "Empty string", | ||
}, | ||
{ | ||
TestName: "No suffix", | ||
InputARN: "arn:aws-us-gov:logs:us-gov-west-1:123456789012:log-group:tf-acc-test-6899758375212691725/1", | ||
ExpectedARN: "arn:aws-us-gov:logs:us-gov-west-1:123456789012:log-group:tf-acc-test-6899758375212691725/1", | ||
}, | ||
{ | ||
TestName: "With suffix", | ||
InputARN: "arn:aws-us-gov:logs:us-gov-west-1:123456789012:log-group:tf-acc-test-6899758375212691725/1:*", | ||
ExpectedARN: "arn:aws-us-gov:logs:us-gov-west-1:123456789012:log-group:tf-acc-test-6899758375212691725/1", | ||
}, | ||
} | ||
|
||
for _, testCase := range testCases { | ||
t.Run(testCase.TestName, func(t *testing.T) { | ||
got := tfcloudwatchlogs.TrimLogGroupARNWildcardSuffix(testCase.InputARN) | ||
|
||
if got != testCase.ExpectedARN { | ||
t.Errorf("got %s, expected %s", got, testCase.ExpectedARN) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters