get Zone
aws.route53.Zone
provides details about a specific Route 53 Hosted Zone. This data source allows to find a Hosted Zone ID given Hosted Zone name and certain search criteria.
Example Usage
The following example shows how to get a Hosted Zone from its name and from this data how to create a Record Set.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const selected = aws.route53.getZone({
name: "test.com.",
privateZone: true,
});
const www = new aws.route53.Record("www", {
zoneId: selected.then(selected => selected.zoneId),
name: selected.then(selected => `www.${selected.name}`),
type: aws.route53.RecordType.A,
ttl: 300,
records: ["10.0.0.1"],
});
import pulumi
import pulumi_aws as aws
selected = aws.route53.get_zone(name="test.com.",
private_zone=True)
www = aws.route53.Record("www",
zone_id=selected.zone_id,
name=f"www.{selected.name}",
type=aws.route53.RecordType.A,
ttl=300,
records=["10.0.0.1"])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var selected = Aws.Route53.GetZone.Invoke(new()
{
Name = "test.com.",
PrivateZone = true,
});
var www = new Aws.Route53.Record("www", new()
{
ZoneId = selected.Apply(getZoneResult => getZoneResult.ZoneId),
Name = $"www.{selected.Apply(getZoneResult => getZoneResult.Name)}",
Type = Aws.Route53.RecordType.A,
Ttl = 300,
Records = new[]
{
"10.0.0.1",
},
});
});
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/route53"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
selected, err := route53.LookupZone(ctx, &route53.LookupZoneArgs{
Name: pulumi.StringRef("test.com."),
PrivateZone: pulumi.BoolRef(true),
}, nil)
if err != nil {
return err
}
_, err = route53.NewRecord(ctx, "www", &route53.RecordArgs{
ZoneId: pulumi.String(selected.ZoneId),
Name: pulumi.Sprintf("www.%v", selected.Name),
Type: pulumi.String(route53.RecordTypeA),
Ttl: pulumi.Int(300),
Records: pulumi.StringArray{
pulumi.String("10.0.0.1"),
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.route53.Route53Functions;
import com.pulumi.aws.route53.inputs.GetZoneArgs;
import com.pulumi.aws.route53.Record;
import com.pulumi.aws.route53.RecordArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var selected = Route53Functions.getZone(GetZoneArgs.builder()
.name("test.com.")
.privateZone(true)
.build());
var www = new Record("www", RecordArgs.builder()
.zoneId(selected.zoneId())
.name(String.format("www.%s", selected.name()))
.type("A")
.ttl(300)
.records("10.0.0.1")
.build());
}
}
resources:
www:
type: aws:route53:Record
properties:
zoneId: ${selected.zoneId}
name: www.${selected.name}
type: A
ttl: '300'
records:
- 10.0.0.1
variables:
selected:
fn::invoke:
function: aws:route53:getZone
arguments:
name: test.com.
privateZone: true
Return
A collection of values returned by getZone.
Parameters
A collection of arguments for invoking getZone.
Return
A collection of values returned by getZone.
Parameters
Hosted Zone name of the desired Hosted Zone.
Used with name
field to get a private Hosted Zone.
Used with name
field. A map of tags, each pair of which must exactly match a pair on the desired Hosted Zone. The arguments of this data source act as filters for querying the available Hosted Zone. You have to use zone_id
or name
, not both of them. The given filter must match exactly one Hosted Zone. If you use name
field for private Hosted Zone, you need to add private_zone
field to true
.
Used with name
field to get a private Hosted Zone associated with the vpc_id (in this case, private_zone is not mandatory).
Hosted Zone id of the desired Hosted Zone.
See also
Return
A collection of values returned by getZone.
Parameters
Builder for com.pulumi.aws.route53.kotlin.inputs.GetZonePlainArgs.