Skip to content

Commit

Permalink
Add secretsmanager
Browse files Browse the repository at this point in the history
At least for the secrets in my account, the resource segment of the ARN has an extra trailing "-xyZ12" piece that isn't part of the secret name and can't be included in the console URL.

For now just throwing an error if that suffix is missing, but please update / LMK if there are secrets without the suffix in the ARN and what their console URLs are so we can make the helper work for them.
  • Loading branch information
dleavitt committed Aug 29, 2024
1 parent 13202af commit 18436fe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 11 additions & 1 deletion link2aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,17 @@ class ARN {
"domain": null,
},
"secretsmanager": { // AWS Secrets Manager
"secret": null,
"secret": () => {
if (this.resource.indexOf("-") === -1) {
// all the secrets I've seen have a "-" delimited suffix
// in the ARN that isn't part of the secret name. For
// now just throwing if the suffix is missing, please
// update if needed.
throw Error(`Secret ARN for ${this.resource} missing suffix`);
}
const name = this.resource.split('-').slice(0, -1).join('-');
return `https://${this.region}.${this.console}/${this.service}/${this.resource_type}?name=${name}`;
},
},
"securityhub": { // AWS Security Hub
"hub": null,
Expand Down
3 changes: 2 additions & 1 deletion testcases/aws-negative.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
"arn:aws:ec2:us-ea st-1:123456789012:instance/asdf",
"arn:aws:ec2:us-ea*st-1:123456789012:instance/asdf",
"arn:aws:ec2:us-ea#st-1:123456789012:instance/asdf",
"arn:aws:ec2:us-ea\\st-1:123456789012:instance/asdf"
"arn:aws:ec2:us-ea\\st-1:123456789012:instance/asdf",
"arn:aws:secretsmanager:us-west-2:123456789012:secret:MySecret9A3F29"
]
3 changes: 2 additions & 1 deletion testcases/aws.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"arn:aws:firehose:us-east-1:123456789012:deliverystream/test-stream": "https://console.aws.amazon.com/firehose/home?region=us-east-1#/details/test-stream/monitoring",

"arn:aws:codeconnections:us-west-2:384862141196:connection/f8234ecc-8990-4e63-b25a-ec36764b7701": "https://us-west-2.console.aws.amazon.com/codesuite/settings/384862141196/us-west-2/codeconnections/connections/f8234ecc-8990-4e63-b25a-ec36764b7701",
"arn:aws:codestar-connections:us-west-2:384862141196:connection/f8234ecc-8990-4e63-b25a-ec36764b7701": "https://us-west-2.console.aws.amazon.com/codesuite/settings/384862141196/us-west-2/codestar-connections/connections/f8234ecc-8990-4e63-b25a-ec36764b7701"
"arn:aws:codestar-connections:us-west-2:384862141196:connection/f8234ecc-8990-4e63-b25a-ec36764b7701": "https://us-west-2.console.aws.amazon.com/codesuite/settings/384862141196/us-west-2/codestar-connections/connections/f8234ecc-8990-4e63-b25a-ec36764b7701",

"arn:aws:secretsmanager:us-west-2:123456789012:secret:MySecret9A3F29-vdHtS43BP1i1-knwb3S": "https://us-west-2.console.aws.amazon.com/secretsmanager/secret?name=MySecret9A3F29-vdHtS43BP1i1"
}

0 comments on commit 18436fe

Please sign in to comment.