Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(route53): Expose VpcEndpointServiceDomainName domain name as a property #16458

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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export class VpcEndpointServiceDomainName extends CoreConstruct {
// Track all domain names created, so someone doesn't accidentally associate two domains with a single service
private static readonly endpointServicesMap: { [endpointService: string]: string} = {};

/**
* The domain name associated with the private DNS configuration
*/
public domainName: string;

// The way this class works is by using three custom resources and a TxtRecord in conjunction
// The first custom resource tells the VPC endpoint service to use the given DNS name
// The VPC endpoint service will then say:
Expand All @@ -58,16 +63,16 @@ export class VpcEndpointServiceDomainName extends CoreConstruct {

const serviceUniqueId = Names.nodeUniqueId(props.endpointService.node);
const serviceId = props.endpointService.vpcEndpointServiceId;
const privateDnsName = props.domainName;
this.domainName = props.domainName;

// Make sure a user doesn't accidentally add multiple domains
this.validateProps(props);

VpcEndpointServiceDomainName.endpointServicesMap[serviceUniqueId] = privateDnsName;
VpcEndpointServiceDomainName.endpointServicesMap[serviceUniqueId] = this.domainName;
VpcEndpointServiceDomainName.endpointServices.push(props.endpointService);

// Enable Private DNS on the endpoint service and retrieve the AWS-generated configuration
const privateDnsConfiguration = this.getPrivateDnsConfiguration(serviceUniqueId, serviceId, privateDnsName);
const privateDnsConfiguration = this.getPrivateDnsConfiguration(serviceUniqueId, serviceId, this.domainName);

// Tell AWS to verify that this account owns the domain attached to the service
this.verifyPrivateDnsConfiguration(privateDnsConfiguration, props.publicHostedZone);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,20 @@ test('throws if creating multiple domains for a single service', () => {
publicHostedZone: zone,
});
}).toThrow(/Cannot create a VpcEndpointServiceDomainName for service/);
});


test('endpoint domain name property equals input domain name', () => {
// GIVEN
vpces = new VpcEndpointService(stack, 'NameTest', {
vpcEndpointServiceLoadBalancers: [nlb],
});

const dn = new VpcEndpointServiceDomainName(stack, 'EndpointDomain', {
endpointService: vpces,
domainName: 'name-test.aws-cdk.dev',
publicHostedZone: zone,
});
expect(dn.domainName).toEqual('name-test.aws-cdk.dev');

});