Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create route53 target for ec2.Instance

See original GitHub issue

🚀 Feature Request

General Information

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change


It would be great to have a route53 target, now that we have an ec2.Instance construct. There should be a possibility to select between the public ip or private ip.

Proposed Solution

Something like this would be nice:

import route53 = require("@aws-cdk/aws-route53");
import targets = require("@aws-cdk/aws-route53-targets");
    const dnsRecord = new route53.ARecord(this, "ARecord", {
      recordName: `windows-bastion.${props.hostedZone.zoneName}`,
      zone: props.hostedZone,
      target: new targets.Ec2InstancePublicIpTarget(instance),
      target: new targets.Ec2InstancePrivateIpTarget(instance) // or
      target: new targets.Ec2InstanceTarget(instance, targets.Ec2InstanceTargetType.PUBLIC_IP)


  • CDK CLI Version: 1.8.0
  • Module Version: 1.8.0
  • OS: macOS Sierra
  • Language: TypeScript

Other information

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

kiros-sccommented, Mar 31, 2020

Hello, I think it would be a really good feature, and why? I’m creating a cdk for the new vpn, creating a new recordSet for it, and I’ve already spent more than 2hours trying to get the record to match the EIP assign to the new instance.

I try with “route53.RecordTarget.fromValues” and “route53.RecordTarget.fromAlias” and nothing, in many cases the record was created ok, correct domainName, but the ip ha no idea where it was coming from. At the end this is the solution I found…

      const vpnDnsRecord = new route53.ARecord(this, "vpnDnsRecord", {
          recordType: RecordType.A,
          recordName: "vpn-xxx",
          zone: hostedZone,
          target: route53.RecordTarget.fromIpAddresses(vpnElasticIP.ref),
          ttl: Duration.seconds(60),

Just so you understand: zone: hostedZone, >> I imported my hostedZone target: route53.RecordTarget.fromIpAddresses(vpnElasticIP.ref), >> I have a const “vpnElasticIP”. Honestly I don’t understand why that work and not the other test, and one thing that I already told in this tickets…

PLEASE IMPROVE CDK DOCUMENTATION (It’s not clear, no examples at all. I don’t want to be the bad person here, but look at terraform documentation to see what good docs are.)

NGL321commented, Oct 7, 2019

Hey @abelmokadem,

Sorry for the slow response, this seems like a reasonable feature to add. If you would like to implement it that would be a great contribution.

As for the particulars of the implementation, unfortunately I am not that familiar with the Route53 construct library. I recommend asking in the Gitter room. @shivlaks is the codeowner for the library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Routing traffic to an ELB load balancer - Amazon Route 53
To route domain traffic to an ELB load balancer, use Amazon Route 53 to create an alias record that points to your load...
Read more >
How to set route53 Alias Target for a domain to a ec2 instance ...
I am trying to configure route53 A record for a domain in its hosted zone using the Alias Target drop down i can...
Read more >
Optimizing Content Delivery with CloudFront & Using Custom ...
... a new EC2 instance 06:26 Testing the website 07:50 Auto-assigned domain names & custom domain names 08:08 Getting started with Route 53...
Read more >
@aws-cdk/aws-route53 - npm
To add a private hosted zone, use PrivateHostedZone . Note that enableDnsHostnames and enableDnsSupport must have been enabled for the VPC you' ...
Read more >
AWS::Route53::RecordSet AliasTarget - 亚马逊云科技
The name of the record that you're creating must match a custom domain name for your API, such as . Amazon Virtual...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found