Skip to content

Commit f8086fc

Browse files
authored
Merge pull request #51 from teamhava/feat/add-resources
Adds a lot of missing resource templates
2 parents b56f607 + 79626cf commit f8086fc

File tree

3 files changed

+60
-14
lines changed

3 files changed

+60
-14
lines changed

link2aws.js

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class ARN {
1212
}
1313

1414
// arn:partition:service:region:account-id:...
15+
this.arn = text;
1516
this.prefix = tokens[0];
1617
this.partition = tokens[1];
1718
this.service = tokens[2];
@@ -187,14 +188,17 @@ class ARN {
187188
"workgroup": null,
188189
},
189190
"autoscaling": { // Amazon EC2 Auto Scaling
190-
"autoScalingGroup": null,
191+
"autoScalingGroup": () => {
192+
const groupName = this.resource.split('/')[1];
193+
return `https://${this.region}.${this.console}/ec2/home?region=${this.region}#AutoScalingGroupDetails:id=${groupName};view=details`
194+
},
191195
"launchConfiguration": null,
192196
},
193197
"aws-marketplace": { // AWS Marketplace Catalog
194198
},
195199
"backup": { // AWS Backup
196200
"backup-plan": null,
197-
"backup-vault": null,
201+
"backup-vault": () => `https://${this.console}/backup/home?region=${this.region}#/backupvaults/details/${this.resource}`,
198202
},
199203
"batch": { // AWS Batch
200204
"job-definition": null,
@@ -228,7 +232,7 @@ class ARN {
228232
"stackset": null,
229233
},
230234
"cloudfront": { // Amazon CloudFront
231-
"distribution": null,
235+
"distribution": () => `https://${this.console}/cloudfront/v4/home#/distributions/${this.resource}`,
232236
"origin-access-identity": null,
233237
"streaming-distribution": null,
234238
},
@@ -449,9 +453,14 @@ class ARN {
449453
"task-set": null,
450454
},
451455
"eks": { // Amazon Elastic Container Service for Kubernetes
452-
"cluster": null,
456+
"cluster": () => `https://${this.console}/eks/home?region=${this.region}#/clusters/${this.resource}`,
453457
"fargateprofile": null,
454-
"nodegroup": null,
458+
"nodegroup": () => {
459+
const arr = this.resource.split('/');
460+
const clusterName = arr[0];
461+
const nodegroupName = arr[1];
462+
return `https://${this.console}/eks/home?region=${this.region}#/clusters/${clusterName}/nodegroups/${nodegroupName}`
463+
},
455464
},
456465
"elastic-inference": { // Amazon Elastic Inference
457466
"elastic-inference-accelerator": null,
@@ -494,7 +503,7 @@ class ARN {
494503
"execute-api": { // Amazon API Gateway
495504
},
496505
"firehose": { // Amazon Kinesis Firehose
497-
"deliverystream": null,
506+
"deliverystream": () => `https://${this.console}/firehose/home?region=${this.region}#/details/${this.resource}/monitoring`,
498507
},
499508
"fms": { // AWS Firewall Manager
500509
"policy": null,
@@ -660,7 +669,7 @@ class ARN {
660669
},
661670
"kms": { // AWS Key Management Service
662671
"alias": null,
663-
"key": null,
672+
"key": () => `https://${this.console}/kms/home?region=${this.region}#/kms/keys/${this.resource}`,
664673
},
665674
"lambda": { // AWS Lambda
666675
"event-source-mapping": null,
@@ -825,19 +834,19 @@ class ARN {
825834
"resource-share-invitation": null,
826835
},
827836
"rds": { // Amazon RDS
828-
"cluster": null,
837+
"cluster": () => `https://${this.console}/rds/home?region=${this.region}#database:id=${this.resource};is-cluster=true`,
829838
"cluster-endpoint": null,
830839
"cluster-pg": null,
831840
"cluster-snapshot": null,
832-
"db": null,
841+
"db": () => `https://${this.console}/rds/home?region=${this.region}#database:id=${this.resource}`,
833842
"db-proxy": null,
834843
"es": null,
835-
"og": null,
844+
"og": () => `https://${this.console}/rds/home?region=${this.region}#option-group-details:option-group-name=${this.resource}`,
836845
"pg": null,
837846
"ri": null,
838847
"secgrp": null,
839-
"snapshot": null,
840-
"subgrp": null,
848+
"snapshot": () => `https://${this.console}/rds/home?region=${this.region}#db-snapshot:id=${this.resource}`,
849+
"subgrp": () => `https://${this.console}/rds/home?region=${this.region}#db-subnet-group:id=${this.resource}`,
841850
"target": null,
842851
"target-group": null,
843852
},
@@ -969,6 +978,7 @@ class ARN {
969978
"": null,
970979
},
971980
"sns": { // Amazon SNS
981+
"": () => `https://${this.console}/sns/v3/home?region=${this.region}#/topic/${this.arn}`,
972982
},
973983
"sqs": { // Amazon SQS
974984
"": () => `https://${this.region}.${this.console}/sqs/v2/home?region=${this.region}#/queues/https%3A%2F%2Fsqs.${this.region}.amazonaws.com%2F${this.account}%2F${this.resource}`
@@ -1044,7 +1054,15 @@ class ARN {
10441054
"webacl": null,
10451055
"xssmatchset": null,
10461056
},
1047-
"wafv2": { // AWS WAF V2
1057+
"wafv2": { // AWS WAF V2
1058+
"global": () => {
1059+
const resource = this.resource.replace("webacl/", "");
1060+
return `https://${this.console}/wafv2/homev2/web-acl/${resource}/overview?region=global`
1061+
},
1062+
"regional": () => {
1063+
const resource = this.resource.replace("webacl/", "");
1064+
return `https://${this.console}/wafv2/homev2/web-acl/${resource}/overview?region=${this.region}`
1065+
}
10481066
},
10491067
"wellarchitected": { // AWS Well-Architected Tool
10501068
"workload": null,

test/test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe('main.ARN', function () {
1313

1414
it('should tokenize ARNs without resource-type', function () {
1515
var arn = new main.ARN('arn:partition:service:region:account-id:resource-id');
16+
assert.equal(arn.arn, 'arn:partition:service:region:account-id:resource-id');
1617
assert.equal(arn.prefix, 'arn');
1718
assert.equal(arn.partition, 'partition');
1819
assert.equal(arn.service, 'service');
@@ -24,6 +25,7 @@ describe('main.ARN', function () {
2425

2526
it('should tokenize ARNs with resource-type/resource-id', function () {
2627
var arn = new main.ARN('arn:partition:service:region:account-id:resource-type/resource-id');
28+
assert.equal(arn.arn, 'arn:partition:service:region:account-id:resource-type/resource-id')
2729
assert.equal(arn.prefix, 'arn');
2830
assert.equal(arn.partition, 'partition');
2931
assert.equal(arn.service, 'service');
@@ -35,6 +37,7 @@ describe('main.ARN', function () {
3537

3638
it('should tokenize ARNs with resource-type:resource-id', function () {
3739
var arn = new main.ARN('arn:partition:service:region:account-id:resource-type:resource-id');
40+
assert.equal(arn.arn, 'arn:partition:service:region:account-id:resource-type:resource-id');
3841
assert.equal(arn.prefix, 'arn');
3942
assert.equal(arn.partition, 'partition');
4043
assert.equal(arn.service, 'service');
@@ -47,6 +50,7 @@ describe('main.ARN', function () {
4750

4851
it('should tokenize ARNs with resource-type:resource-id-qualifier-1:qualifier-2:qualifier-3', function () {
4952
var arn = new main.ARN('arn:partition:service:region:account-id:resource-type:resource-id-qualifier-1:qualifier-2:qualifier-3');
53+
assert.equal(arn.arn, 'arn:partition:service:region:account-id:resource-type:resource-id-qualifier-1:qualifier-2:qualifier-3');
5054
assert.equal(arn.prefix, 'arn');
5155
assert.equal(arn.partition, 'partition');
5256
assert.equal(arn.service, 'service');

testcases/aws.json

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,29 @@
5151
"arn:aws:amplify:sa-east-1:384862141196:apps/aaaaaaaaa/branches/master/jobs/00000001810": "https://sa-east-1.console.aws.amazon.com/amplify/home?region=sa-east-1#/aaaaaaaaa/master/1810",
5252
"arn:aws:amplify:sa-east-1:384862141196:apps/test-null-path": null,
5353

54-
"arn:aws:codepipeline:us-east-1:115131055398:my-pipeline": "https://us-east-1.console.aws.amazon.com/codesuite/codepipeline/pipelines/my-pipeline/view?region=us-east-1"
54+
"arn:aws:codepipeline:us-east-1:115131055398:my-pipeline": "https://us-east-1.console.aws.amazon.com/codesuite/codepipeline/pipelines/my-pipeline/view?region=us-east-1",
55+
56+
"arn:aws:cloudfront::123456789012:distribution/E2YDLZ26QPSF11": "https://console.aws.amazon.com/cloudfront/v4/home#/distributions/E2YDLZ26QPSF11",
57+
58+
"arn:aws:autoscaling:us-east-1:123456789012:autoScalingGroup:034d7396-90f3-r8si-88f5-ff1dcc0eb80e:autoScalingGroupName/test": "https://us-east-1.console.aws.amazon.com/ec2/home?region=us-east-1#AutoScalingGroupDetails:id=test;view=details",
59+
60+
"arn:aws:wafv2:us-east-1:123456789012:global/webacl/test/f8234ecc-8990-4e63-b25a-ec36764b7701": "https://console.aws.amazon.com/wafv2/homev2/web-acl/test/f8234ecc-8990-4e63-b25a-ec36764b7701/overview?region=global",
61+
"arn:aws:wafv2:us-east-1:123456789012:regional/webacl/test/0089db7f-b629-4ba6-bdad-8b2f3ec31c86": "https://console.aws.amazon.com/wafv2/homev2/web-acl/test/0089db7f-b629-4ba6-bdad-8b2f3ec31c86/overview?region=us-east-1",
62+
63+
"arn:aws:sns:us-east-1:123456789012:sns-topic": "https://console.aws.amazon.com/sns/v3/home?region=us-east-1#/topic/arn:aws:sns:us-east-1:123456789012:sns-topic",
64+
65+
"arn:aws:rds:us-east-1:123456789012:db:test-db": "https://console.aws.amazon.com/rds/home?region=us-east-1#database:id=test-db",
66+
"arn:aws:rds:us-east-1:123456789012:snapshot:rds:test-db-2024-02-04-22-12": "https://console.aws.amazon.com/rds/home?region=us-east-1#db-snapshot:id=rds:test-db-2024-02-04-22-12",
67+
"arn:aws:rds:us-east-1:123456789012:subgrp:test-db": "https://console.aws.amazon.com/rds/home?region=us-east-1#db-subnet-group:id=test-db",
68+
"arn:aws:rds:us-east-1:123456789012:og:test-db": "https://console.aws.amazon.com/rds/home?region=us-east-1#option-group-details:option-group-name=test-db",
69+
"arn:aws:rds:us-east-1:123456789012:cluster:test-cluster": "https://console.aws.amazon.com/rds/home?region=us-east-1#database:id=test-cluster;is-cluster=true",
70+
71+
"arn:aws:kms:us-east-1:123456789012:key/4bd42b4b-af95-4698-b685-58d3296890fe": "https://console.aws.amazon.com/kms/home?region=us-east-1#/kms/keys/4bd42b4b-af95-4698-b685-58d3296890fe",
72+
73+
"arn:aws:eks:us-east-1:123456789012:cluster/test-cluster": "https://console.aws.amazon.com/eks/home?region=us-east-1#/clusters/test-cluster",
74+
"arn:aws:eks:us-east-1:123456789012:nodegroup/test-cluster/test-workers/a2c51527-da50-031f-1130-c5d5d77be06c": "https://console.aws.amazon.com/eks/home?region=us-east-1#/clusters/test-cluster/nodegroups/test-workers",
75+
76+
"arn:aws:backup:us-east-1:123456789012:backup-vault:backups-primary": "https://console.aws.amazon.com/backup/home?region=us-east-1#/backupvaults/details/backups-primary",
77+
78+
"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"
5579
}

0 commit comments

Comments
 (0)