How to use the Route53 function from aws-sdk

Find comprehensive JavaScript aws-sdk.Route53 code examples handpicked from public code repositorys.

aws-sdk.Route53 is a service in the AWS SDK that allows you to manage DNS settings for your domains and routes traffic to resources on the internet.

6
7
8
9
10
11
12
13
14

const deleteDomainName = util.promisify(
  apigatewayv2.deleteDomainName.bind(apigatewayv2)
);

const route53 = new aws.Route53({
  apiVersion: '2014-05-15',
  region: 'us-east-1',
});
fork icon0
star icon1
watch icon1

6
7
8
9
10
11
12
13
14
    return;
}

console.log("Get HostedZone Name for =>" + JSON.stringify(event));
var hostedZoneId = event.ResourceProperties.hostedZoneId;
var route53 = new aws.Route53({apiVersion: '2013-04-01'});
route53.getHostedZone({Id: hostedZoneId}, function(err, data) {

    if (err == undefined) {
fork icon0
star icon0
watch icon1

How does aws-sdk.Route53 work?

aws-sdk.Route53 is a service in the AWS SDK that allows you to manage DNS settings for your domains and routes traffic to resources on the internet. When you use aws-sdk.Route53, you can perform a variety of operations related to DNS management and traffic routing, including: Creating and managing hosted zones: A hosted zone is a container for your DNS records, which defines how traffic is routed for a specific domain or subdomain. Creating and managing DNS records: A DNS record is a mapping between a domain name and an IP address, which tells clients how to route traffic for that domain. Configuring DNS settings: You can configure a variety of settings for your DNS records, including TTL (time to live), routing policies, and health checks. Routing traffic to resources: You can use Route53 to route traffic to various resources, including EC2 instances, Elastic Load Balancers, and S3 buckets. Overall, aws-sdk.Route53 is a powerful service in the AWS SDK that allows you to manage your DNS settings and route traffic to your resources on the internet. It provides a wide range of features and options for DNS management, making it a valuable tool for many different types of applications and use cases.

Ai Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const AWS = require("aws-sdk");

// Configure the AWS SDK with your access keys and region
AWS.config.update({
  accessKeyId: "your_access_key",
  secretAccessKey: "your_secret_key",
  region: "us-east-1",
});

// Create a new Route53 object
const route53 = new AWS.Route53();

// Create a new hosted zone
const params = {
  Name: "example.com",
  CallerReference: new Date().getTime().toString(),
};

route53.createHostedZone(params, (err, data) => {
  if (err) {
    console.error(err);
  } else {
    console.log(data);

    // Create new DNS records for the hosted zone
    const hostedZoneId = data.HostedZone.Id.replace("/hostedzone/", "");
    const changes = [
      {
        Action: "CREATE",
        ResourceRecordSet: {
          Name: "example.com",
          Type: "A",
          TTL: 300,
          ResourceRecords: [{ Value: "192.0.2.1" }],
        },
      },
      {
        Action: "CREATE",
        ResourceRecordSet: {
          Name: "www.example.com",
          Type: "CNAME",
          TTL: 300,
          ResourceRecords: [{ Value: "example.com" }],
        },
      },
    ];

    const changeParams = {
      ChangeBatch: {
        Changes: changes,
      },
      HostedZoneId: hostedZoneId,
    };

    route53.changeResourceRecordSets(changeParams, (err, data) => {
      if (err) {
        console.error(err);
      } else {
        console.log(data);
      }
    });
  }
});

In this example, we first configure the AWS SDK with our access keys and region, and create a new Route53 object using new AWS.Route53(). We then call route53.createHostedZone(params) to create a new hosted zone named example.com. The params object specifies the name of the hosted zone and a unique CallerReference value. After the hosted zone is created, we extract its ID from the response data and use it to create two new DNS records using route53.changeResourceRecordSets(changeParams). The changeParams object specifies the changes to be made to the DNS records, including creating a new A record for example.com and a new CNAME record for www.example.com. When the code is run, it creates a new hosted zone and DNS records in Route53. Overall, this example demonstrates how to use aws-sdk.Route53 to create a new hosted zone and DNS records in Route53 using the AWS SDK.