Skip to content

Commit

Permalink
feat(ec2): expose interface endpoint service shortname (aws#20965)
Browse files Browse the repository at this point in the history
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*
  • Loading branch information
hoegertn authored and daschaa committed Jul 9, 2022
1 parent 4ec4087 commit 004725b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -348,6 +353,7 @@ export class InterfaceVpcEndpointAwsService implements IInterfaceVpcEndpointServ
});

this.name = `${prefix || defaultEndpointPrefix}.${region}.${name}${defaultEndpointSuffix}`;
this.shortName = name;
this.port = port || 443;
}

Expand Down
7 changes: 7 additions & 0 deletions packages/@aws-cdk/aws-ec2/test/vpc-endpoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 004725b

Please sign in to comment.