cdklabs / cdk-monitoring-constructs

Easy-to-use CDK constructs for monitoring your AWS infrastructure
https://constructs.dev/packages/cdk-monitoring-constructs
Apache License 2.0
443 stars 55 forks source link

Elasticache Cluster URLs Don't Appear to Be Correct #523

Closed dleavitt closed 1 month ago

dleavitt commented 1 month ago

Version

7.10.1

Steps and/or minimal code example to reproduce

Create some elasticache monitoring instances or just do the following:

import { Stack } from "aws-cdk-lib";
import {
  AwsConsoleUrlFactory,
  ElastiCacheClusterType,
} from "cdk-monitoring-constructs";

const stack = new Stack();

const f = new AwsConsoleUrlFactory({
  awsAccountId: "123",
  awsAccountRegion: "us-east-1",
});

let r = f.getElastiCacheClusterUrl("c1", ElastiCacheClusterType.REDIS);
let m = f.getElastiCacheClusterUrl("c2", ElastiCacheClusterType.MEMCACHED);

console.log({ redis: stack.resolve(r), memcached: stack.resolve(m) });

Expected behavior

The urls should look like: https://us-east-1.console.aws.amazon.com/elasticache/home?region=us-east-1#/redis/c1 https://us-east-1.console.aws.amazon.com/elasticache/home?region=us-east-1#/memcached/c2

Even if the clusters don't exist you can tell that the form of the URL is correct - the fields on the page will just be missing.

Actual behavior

You'll get URLs of the form: https://us-east-1.console.aws.amazon.com/elasticache/home?region=us-east-1#redis-shards:redis-id=c1 https://us-east-1.console.aws.amazon.com/elasticache/home?region=us-east-1#memcached-nodes:id=c2;nodes

Which don't work - they'll bounce you to the elasticache landing page.

Other details

I'm not sure the console URLs are documented anywhere, so it's possible that this is different for different accounts or elasticache setups.

dleavitt commented 1 month ago

As a side-note, making clusterUrl read-only exacerbates this, as the user has to create a subclass and override createTitleWidget in order to fix, rather than just setting the correct url on the instance.

https://github.com/cdklabs/cdk-monitoring-constructs/blob/d1fda6fd7ea7ae2e07d9ae847273794474f9b36f/lib/monitoring/aws-elasticache/ElastiCacheClusterMonitoring.ts#L93

Any reason it's read-only?