Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/aws-elasticache/serverless-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ export class ServerlessCache extends ServerlessCacheBase {
this.serverlessCacheName = serverlessCache.ref;

this.endpointAddress = serverlessCache.attrEndpointAddress;
this.endpointPort = Number(serverlessCache.attrEndpointPort);
this.endpointPort = Token.asNumber(serverlessCache.attrEndpointPort);

this.connections = new aws_ec2.Connections({
securityGroups: this.securityGroups,
Expand Down
24 changes: 24 additions & 0 deletions test/aws-elasticache/serverless-cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,30 @@ describe('ElastiCache Serverless Cache', () => {
});
});

test('should correctly export properties to dependencies', () => {
const cache = new ServerlessCache(stack, 'ServerlessCache', {
engine: Engine.VALKEY,
vpc,
majorEngineVersion: MajorVersion.VER_8,
});
const dependentStack = new Stack(app, 'DependentStack', {});
new SecurityGroup(dependentStack, 'SecurityGroup', { vpc }).connections.allowToDefaultPort(cache);

Template.fromStack(stack).hasOutput('ExportsOutputFnGetAttServerlessCacheDFFA799DEndpointPort48E77897', {
Export: {
Name: 'TestStack:ExportsOutputFnGetAttServerlessCacheDFFA799DEndpointPort48E77897',
},
Value: {
'Fn::GetAtt': ['ServerlessCacheDFFA799D', 'Endpoint.Port'],
},
});
Template.fromStack(dependentStack).hasResourceProperties('AWS::EC2::SecurityGroupIngress', {
FromPort: {
'Fn::ImportValue': 'TestStack:ExportsOutputFnGetAttServerlessCacheDFFA799DEndpointPort48E77897',
},
});
});

test('Create a serverless cache with maximum properties', () => {
const user = new NoPasswordRequiredUser(stack, 'User', {});

Expand Down