From a50be4efffd1f01f71f587b762005441a1cb1550 Mon Sep 17 00:00:00 2001 From: Adam Hall Date: Fri, 1 Sep 2023 11:10:20 +0930 Subject: [PATCH] Update connection strings to use tokens for attribute references as they are evaluating to null when using the toString() method --- packages/graphql-mesh-server/lib/fargate.ts | 6 +++--- packages/graphql-mesh-server/lib/redis-construct.ts | 12 ++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/graphql-mesh-server/lib/fargate.ts b/packages/graphql-mesh-server/lib/fargate.ts index 7a36cfb6..10081be1 100644 --- a/packages/graphql-mesh-server/lib/fargate.ts +++ b/packages/graphql-mesh-server/lib/fargate.ts @@ -1,5 +1,5 @@ import { Construct } from 'constructs'; -import { Duration } from 'aws-cdk-lib'; +import { Duration, Token } from 'aws-cdk-lib'; import { RemovalPolicy } from 'aws-cdk-lib'; import * as acm from 'aws-cdk-lib/aws-certificatemanager'; import * as ecs from 'aws-cdk-lib/aws-ecs'; @@ -129,11 +129,11 @@ export class MeshService extends Construct { if (props.redis) { props.redis.securityGroup.addIngressRule( securityGroup, - Port.tcp(Number(props.redis.connectionPort)) + Port.tcp(props.redis.connectionPort) ); environment['REDIS_ENDPOINT'] = props.redis.connectionEndPoint; - environment['REDIS_PORT'] = props.redis.connectionPort; + environment['REDIS_PORT'] = props.redis.connectionPort.toString(); } // Construct secrets from provided ssm values diff --git a/packages/graphql-mesh-server/lib/redis-construct.ts b/packages/graphql-mesh-server/lib/redis-construct.ts index a0319f43..f88526b0 100644 --- a/packages/graphql-mesh-server/lib/redis-construct.ts +++ b/packages/graphql-mesh-server/lib/redis-construct.ts @@ -4,7 +4,7 @@ import { CfnSubnetGroup, CfnParameterGroup, } from 'aws-cdk-lib/aws-elasticache'; -import { CfnOutput } from 'aws-cdk-lib'; +import { CfnOutput, Reference, Token } from 'aws-cdk-lib'; import { Construct } from 'constructs'; export interface RedisServiceProps { @@ -83,14 +83,10 @@ export class RedisService extends Construct { } public get connectionEndPoint(): string { - return this.cacheCluster - .getAtt('RedisEndpoint.Address') - .toString(); + return Token.asString(this.cacheCluster.getAtt('RedisEndpoint.Address')) } - public get connectionPort(): string { - return this.cacheCluster - .getAtt('RedisEndpoint.Port') - .toString(); + public get connectionPort(): number { + return Token.asNumber(this.cacheCluster.getAtt('RedisEndpoint.Port')); } }