link2aws 1.0.22 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/link2aws.js +16 -4
  2. package/package.json +1 -1
package/link2aws.js CHANGED
@@ -57,8 +57,13 @@ class ARN {
57
57
  }
58
58
  }
59
59
 
60
- // ...:resource-type/resource-id (resource-id can contain slashes!)
61
- else if (typeof (tokens[5]) != 'undefined' && tokens[5].indexOf('/') > 0) {
60
+ // ...:resource-type/resource-id (common case)
61
+ // ...:/resource-type/resource-id (apigateway)
62
+ // resource-id can contain slashes.
63
+ else if (typeof (tokens[5]) != 'undefined' && tokens[5].slice(1).indexOf('/') >= 0) {
64
+ if (tokens[5].startsWith('/')) {
65
+ tokens[5] = tokens[5].slice(1);
66
+ }
62
67
  this.resource_type = tokens[5].slice(0, tokens[5].indexOf('/'));
63
68
  this.resource = tokens[5].slice(tokens[5].indexOf('/') + 1, tokens[5].length);
64
69
  this.hasPath = true;
@@ -182,7 +187,7 @@ class ARN {
182
187
  },
183
188
  },
184
189
  "apigateway": { // Manage Amazon API Gateway
185
- "": null,
190
+ "restapis": () => `https://${this.region}.${this.console}/apigateway/main/apis/${this.resource}/resources?api=${this.resource}&region=${this.region}`,
186
191
  },
187
192
  "appconfig": { // AWS AppConfig
188
193
  "application": null,
@@ -978,7 +983,14 @@ class ARN {
978
983
  "domain": null,
979
984
  },
980
985
  "secretsmanager": { // AWS Secrets Manager
981
- "secret": null,
986
+ "secret": () => {
987
+ const arnSuffix = /-\w{6}$/;
988
+ if (!arnSuffix.test(this.resource)) {
989
+ throw Error(`Secret ARN for "${this.resource}" appears invalid, should end with ${arnSuffix}`);
990
+ }
991
+ const name = this.resource.replace(arnSuffix, "");
992
+ return `https://${this.region}.${this.console}/${this.service}/${this.resource_type}?name=${name}`;
993
+ },
982
994
  },
983
995
  "securityhub": { // AWS Security Hub
984
996
  "hub": null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "link2aws",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "Convert ARN (Amazon Resource Name) to AWS Console link",
5
5
  "main": "link2aws.js",
6
6
  "directories": {