Skip to content

Commit

Permalink
feat(route53-targets): Add aws-route53-targets/InterfaceVpcEndpointTa…
Browse files Browse the repository at this point in the history
…rget (#4868)

* Add InterfaceVpcEndpointTarget

* Update RecordTarget

* Revert yarn.lock

* Fix tests

* Revert integ json

* Rename r53 to route53

* Rename r53 to route53

* Update tests, and README

* Fix devDep

* Remove newline

* Fix grammar
  • Loading branch information
KingOfPoptart authored and mergify[bot] committed Jan 16, 2020
1 parent a1cd743 commit 6969562
Show file tree
Hide file tree
Showing 7 changed files with 807 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/@aws-cdk/aws-route53-targets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ This library contains Route53 Alias Record targets for:
// or - route53.RecordTarget.fromAlias(new alias.ApiGatewayDomainName(domainName)),
});
```
* InterfaceVpcEndpoints

**Important:** Based on the CFN docs for VPCEndpoints - [see here](attrDnsEntries) - the attributes returned for DnsEntries in CloudFormation is a combination of the hosted zone ID and the DNS name. The entries are ordered as follows: regional public DNS, zonal public DNS, private DNS, and wildcard DNS. This order is not enforced for AWS Marketplace services, and therefore this CDK construct is ONLY guaranteed to work with non-marketplace services.
```ts
new route53.ARecord(stack, "AliasRecord", {
zone,
target: route53.RecordTarget.fromAlias(new alias.InterfaceVpcEndpointTarget(interfaceVpcEndpoint))
});
```
* S3 Bucket WebSite:

**Important:** The Bucket name must strictly match the full DNS name.
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-route53-targets/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './bucket-website-target';
export * from './classic-load-balancer-target';
export * from './cloudfront-target';
export * from './load-balancer-target';
export * from './interface-vpc-endpoint-target';
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as ec2 from '@aws-cdk/aws-ec2';
import * as route53 from '@aws-cdk/aws-route53';
import * as cdk from '@aws-cdk/core';

/**
* Set an InterfaceVpcEndpoint as a target for an ARecord
*/
export class InterfaceVpcEndpointTarget implements route53.IAliasRecordTarget {
private readonly cfnVpcEndpoint: ec2.CfnVPCEndpoint;
constructor(private readonly vpcEndpoint: ec2.IInterfaceVpcEndpoint) {
this.cfnVpcEndpoint = this.vpcEndpoint.node.findChild('Resource') as ec2.CfnVPCEndpoint;
}

public bind(_record: route53.IRecordSet): route53.AliasRecordTargetConfig {
return {
dnsName: cdk.Fn.select(1, cdk.Fn.split(':', cdk.Fn.select(0, this.cfnVpcEndpoint.attrDnsEntries))),
hostedZoneId: cdk.Fn.select(0, cdk.Fn.split(':', cdk.Fn.select(0, this.cfnVpcEndpoint.attrDnsEntries))),
};
}
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-route53-targets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
"devDependencies": {
"@aws-cdk/assert": "1.21.0",
"@aws-cdk/aws-certificatemanager": "1.21.0",
"@aws-cdk/aws-ec2": "1.21.0",
"@aws-cdk/aws-lambda": "1.21.0",
"cdk-build-tools": "1.21.0",
"cdk-integ-tools": "1.21.0",
Expand All @@ -89,6 +88,7 @@
"dependencies": {
"@aws-cdk/aws-apigateway": "1.21.0",
"@aws-cdk/aws-cloudfront": "1.21.0",
"@aws-cdk/aws-ec2": "1.21.0",
"@aws-cdk/aws-elasticloadbalancing": "1.21.0",
"@aws-cdk/aws-elasticloadbalancingv2": "1.21.0",
"@aws-cdk/aws-iam": "1.21.0",
Expand Down
Loading

0 comments on commit 6969562

Please sign in to comment.