From 004725b95b6c62c6e384659a1ee80ed99da7d4f0 Mon Sep 17 00:00:00 2001 From: Thorsten Hoeger Date: Wed, 6 Jul 2022 23:53:44 +0200 Subject: [PATCH] feat(ec2): expose interface endpoint service shortname (#20965) This PR exposes the short name of the InterfaceVpcEndpointService as an additional property. This helps constructs getting it as a param to derive the service name without parsing regional reverse-FQDNs. As it only adds a property, I think no readme change is needed here. ---- ### All Submissions: * [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts | 8 +++++++- packages/@aws-cdk/aws-ec2/test/vpc-endpoint.test.ts | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts b/packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts index 85c77c4395c96..ccb23517c4ff6 100644 --- a/packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts +++ b/packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts @@ -316,10 +316,15 @@ export class InterfaceVpcEndpointAwsService implements IInterfaceVpcEndpointServ public static readonly XRAY = new InterfaceVpcEndpointAwsService('xray'); /** - * The name of the service. + * The name of the service. e.g. com.amazonaws.us-east-1.ecs */ public readonly name: string; + /** + * The short name of the service. e.g. ecs + */ + public readonly shortName: string; + /** * The port of the service. */ @@ -348,6 +353,7 @@ export class InterfaceVpcEndpointAwsService implements IInterfaceVpcEndpointServ }); this.name = `${prefix || defaultEndpointPrefix}.${region}.${name}${defaultEndpointSuffix}`; + this.shortName = name; this.port = port || 443; } diff --git a/packages/@aws-cdk/aws-ec2/test/vpc-endpoint.test.ts b/packages/@aws-cdk/aws-ec2/test/vpc-endpoint.test.ts index 9baa7c9e7e437..7ad9568478b51 100644 --- a/packages/@aws-cdk/aws-ec2/test/vpc-endpoint.test.ts +++ b/packages/@aws-cdk/aws-ec2/test/vpc-endpoint.test.ts @@ -268,6 +268,13 @@ describe('vpc endpoint', () => { }); + describe('interface endpoint retains service name in shortName property', () => { + test('shortName property', () => { + expect(InterfaceVpcEndpointAwsService.ECS.shortName).toBe('ecs'); + expect(InterfaceVpcEndpointAwsService.ECR_DOCKER.shortName).toBe('ecr.dkr'); + }); + }); + describe('add interface endpoint to looked-up VPC', () => { test('initial run', () => { // GIVEN