File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package aws
33import (
44 "github.com/aws/aws-sdk-go/aws/session"
55 "github.com/aws/aws-sdk-go/service/kms"
6+ "github.com/aws/aws-sdk-go/aws"
67)
78
89func CreateKmsClient (awsRegion string ) (* kms.KMS , error ) {
@@ -13,3 +14,24 @@ func CreateKmsClient(awsRegion string) (*kms.KMS, error) {
1314
1415 return kms .New (session .New (), awsConfig ), nil
1516}
17+
18+ // This exists because KMS keys cost $1/mo for each one created. In our automated tests, we often run 100s times in,
19+ // especially during inital development when debugging. Rather than create a new key each time we run a test and incurring
20+ // the $1 charge, a dedicated key with the alias 'dedicated-test-key' has been created in each region. This method allows
21+ // this key to be retrieved and used for testing purposes.
22+ func GetDedicatedTestKeyArn (awsRegion string ) (string , error ) {
23+ kmsClient , err := CreateKmsClient (awsRegion )
24+ if err != nil {
25+ return "" , err
26+ }
27+
28+ result , err := kmsClient .DescribeKey (& kms.DescribeKeyInput {
29+ KeyId : aws .String ("alias/dedicated-test-key" ),
30+ })
31+
32+ if err != nil {
33+ return "" , err
34+ }
35+
36+ return * result .KeyMetadata .Arn , nil
37+ }
You can’t perform that action at this time.
0 commit comments