AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi
aws.route53.getZone
Explore with Pulumi AI
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"])
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
})
}
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 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.applyValue(getZoneResult -> getZoneResult.zoneId()))
.name(String.format("www.%s", selected.applyValue(getZoneResult -> getZoneResult.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
Using getZone
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getZone(args: GetZoneArgs, opts?: InvokeOptions): Promise<GetZoneResult>
function getZoneOutput(args: GetZoneOutputArgs, opts?: InvokeOptions): Output<GetZoneResult>
def get_zone(name: Optional[str] = None,
private_zone: Optional[bool] = None,
tags: Optional[Mapping[str, str]] = None,
vpc_id: Optional[str] = None,
zone_id: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetZoneResult
def get_zone_output(name: Optional[pulumi.Input[str]] = None,
private_zone: Optional[pulumi.Input[bool]] = None,
tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
vpc_id: Optional[pulumi.Input[str]] = None,
zone_id: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetZoneResult]
func LookupZone(ctx *Context, args *LookupZoneArgs, opts ...InvokeOption) (*LookupZoneResult, error)
func LookupZoneOutput(ctx *Context, args *LookupZoneOutputArgs, opts ...InvokeOption) LookupZoneResultOutput
> Note: This function is named LookupZone
in the Go SDK.
public static class GetZone
{
public static Task<GetZoneResult> InvokeAsync(GetZoneArgs args, InvokeOptions? opts = null)
public static Output<GetZoneResult> Invoke(GetZoneInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetZoneResult> getZone(GetZoneArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: aws:route53/getZone:getZone
arguments:
# arguments dictionary
The following arguments are supported:
- Name string
- Hosted Zone name of the desired Hosted Zone.
- Private
Zone bool - Used with
name
field to get a private Hosted Zone. - Dictionary<string, string>
- Used with
name
field. A map of tags, each pair of which must exactly match a pair on the desired Hosted Zone. - Vpc
Id string - Used with
name
field to get a private Hosted Zone associated with the vpc_id (in this case, private_zone is not mandatory). - Zone
Id string - Hosted Zone id of the desired Hosted Zone.
- Name string
- Hosted Zone name of the desired Hosted Zone.
- Private
Zone bool - Used with
name
field to get a private Hosted Zone. - map[string]string
- Used with
name
field. A map of tags, each pair of which must exactly match a pair on the desired Hosted Zone. - Vpc
Id string - Used with
name
field to get a private Hosted Zone associated with the vpc_id (in this case, private_zone is not mandatory). - Zone
Id string - Hosted Zone id of the desired Hosted Zone.
- name String
- Hosted Zone name of the desired Hosted Zone.
- private
Zone Boolean - Used with
name
field to get a private Hosted Zone. - Map<String,String>
- Used with
name
field. A map of tags, each pair of which must exactly match a pair on the desired Hosted Zone. - vpc
Id String - Used with
name
field to get a private Hosted Zone associated with the vpc_id (in this case, private_zone is not mandatory). - zone
Id String - Hosted Zone id of the desired Hosted Zone.
- name string
- Hosted Zone name of the desired Hosted Zone.
- private
Zone boolean - Used with
name
field to get a private Hosted Zone. - {[key: string]: string}
- Used with
name
field. A map of tags, each pair of which must exactly match a pair on the desired Hosted Zone. - vpc
Id string - Used with
name
field to get a private Hosted Zone associated with the vpc_id (in this case, private_zone is not mandatory). - zone
Id string - Hosted Zone id of the desired Hosted Zone.
- name str
- Hosted Zone name of the desired Hosted Zone.
- private_
zone bool - Used with
name
field to get a private Hosted Zone. - Mapping[str, str]
- Used with
name
field. A map of tags, each pair of which must exactly match a pair on the desired Hosted Zone. - vpc_
id str - Used with
name
field to get a private Hosted Zone associated with the vpc_id (in this case, private_zone is not mandatory). - zone_
id str - Hosted Zone id of the desired Hosted Zone.
- name String
- Hosted Zone name of the desired Hosted Zone.
- private
Zone Boolean - Used with
name
field to get a private Hosted Zone. - Map<String>
- Used with
name
field. A map of tags, each pair of which must exactly match a pair on the desired Hosted Zone. - vpc
Id String - Used with
name
field to get a private Hosted Zone associated with the vpc_id (in this case, private_zone is not mandatory). - zone
Id String - Hosted Zone id of the desired Hosted Zone.
getZone Result
The following output properties are available:
- Arn string
- ARN of the Hosted Zone.
- Caller
Reference string - Caller Reference of the Hosted Zone.
- Comment string
- Comment field of the Hosted Zone.
- Id string
- The provider-assigned unique ID for this managed resource.
- Linked
Service stringDescription - The description provided by the service that created the Hosted Zone (e.g.,
arn:aws:servicediscovery:us-east-1:1234567890:namespace/ns-xxxxxxxxxxxxxxxx
). - Linked
Service stringPrincipal - The service that created the Hosted Zone (e.g.,
servicediscovery.amazonaws.com
). - Name string
- The Hosted Zone name.
- Name
Servers List<string> - List of DNS name servers for the Hosted Zone.
- Primary
Name stringServer - The Route 53 name server that created the SOA record.
- Resource
Record intSet Count - The number of Record Set in the Hosted Zone.
- Dictionary<string, string>
- A map of tags assigned to the Hosted Zone.
- Vpc
Id string - Zone
Id string - The Hosted Zone identifier.
- Private
Zone bool - Indicates whether this is a private hosted zone.
- Arn string
- ARN of the Hosted Zone.
- Caller
Reference string - Caller Reference of the Hosted Zone.
- Comment string
- Comment field of the Hosted Zone.
- Id string
- The provider-assigned unique ID for this managed resource.
- Linked
Service stringDescription - The description provided by the service that created the Hosted Zone (e.g.,
arn:aws:servicediscovery:us-east-1:1234567890:namespace/ns-xxxxxxxxxxxxxxxx
). - Linked
Service stringPrincipal - The service that created the Hosted Zone (e.g.,
servicediscovery.amazonaws.com
). - Name string
- The Hosted Zone name.
- Name
Servers []string - List of DNS name servers for the Hosted Zone.
- Primary
Name stringServer - The Route 53 name server that created the SOA record.
- Resource
Record intSet Count - The number of Record Set in the Hosted Zone.
- map[string]string
- A map of tags assigned to the Hosted Zone.
- Vpc
Id string - Zone
Id string - The Hosted Zone identifier.
- Private
Zone bool - Indicates whether this is a private hosted zone.
- arn String
- ARN of the Hosted Zone.
- caller
Reference String - Caller Reference of the Hosted Zone.
- comment String
- Comment field of the Hosted Zone.
- id String
- The provider-assigned unique ID for this managed resource.
- linked
Service StringDescription - The description provided by the service that created the Hosted Zone (e.g.,
arn:aws:servicediscovery:us-east-1:1234567890:namespace/ns-xxxxxxxxxxxxxxxx
). - linked
Service StringPrincipal - The service that created the Hosted Zone (e.g.,
servicediscovery.amazonaws.com
). - name String
- The Hosted Zone name.
- name
Servers List<String> - List of DNS name servers for the Hosted Zone.
- primary
Name StringServer - The Route 53 name server that created the SOA record.
- resource
Record IntegerSet Count - The number of Record Set in the Hosted Zone.
- Map<String,String>
- A map of tags assigned to the Hosted Zone.
- vpc
Id String - zone
Id String - The Hosted Zone identifier.
- private
Zone Boolean - Indicates whether this is a private hosted zone.
- arn string
- ARN of the Hosted Zone.
- caller
Reference string - Caller Reference of the Hosted Zone.
- comment string
- Comment field of the Hosted Zone.
- id string
- The provider-assigned unique ID for this managed resource.
- linked
Service stringDescription - The description provided by the service that created the Hosted Zone (e.g.,
arn:aws:servicediscovery:us-east-1:1234567890:namespace/ns-xxxxxxxxxxxxxxxx
). - linked
Service stringPrincipal - The service that created the Hosted Zone (e.g.,
servicediscovery.amazonaws.com
). - name string
- The Hosted Zone name.
- name
Servers string[] - List of DNS name servers for the Hosted Zone.
- primary
Name stringServer - The Route 53 name server that created the SOA record.
- resource
Record numberSet Count - The number of Record Set in the Hosted Zone.
- {[key: string]: string}
- A map of tags assigned to the Hosted Zone.
- vpc
Id string - zone
Id string - The Hosted Zone identifier.
- private
Zone boolean - Indicates whether this is a private hosted zone.
- arn str
- ARN of the Hosted Zone.
- caller_
reference str - Caller Reference of the Hosted Zone.
- comment str
- Comment field of the Hosted Zone.
- id str
- The provider-assigned unique ID for this managed resource.
- linked_
service_ strdescription - The description provided by the service that created the Hosted Zone (e.g.,
arn:aws:servicediscovery:us-east-1:1234567890:namespace/ns-xxxxxxxxxxxxxxxx
). - linked_
service_ strprincipal - The service that created the Hosted Zone (e.g.,
servicediscovery.amazonaws.com
). - name str
- The Hosted Zone name.
- name_
servers Sequence[str] - List of DNS name servers for the Hosted Zone.
- primary_
name_ strserver - The Route 53 name server that created the SOA record.
- resource_
record_ intset_ count - The number of Record Set in the Hosted Zone.
- Mapping[str, str]
- A map of tags assigned to the Hosted Zone.
- vpc_
id str - zone_
id str - The Hosted Zone identifier.
- private_
zone bool - Indicates whether this is a private hosted zone.
- arn String
- ARN of the Hosted Zone.
- caller
Reference String - Caller Reference of the Hosted Zone.
- comment String
- Comment field of the Hosted Zone.
- id String
- The provider-assigned unique ID for this managed resource.
- linked
Service StringDescription - The description provided by the service that created the Hosted Zone (e.g.,
arn:aws:servicediscovery:us-east-1:1234567890:namespace/ns-xxxxxxxxxxxxxxxx
). - linked
Service StringPrincipal - The service that created the Hosted Zone (e.g.,
servicediscovery.amazonaws.com
). - name String
- The Hosted Zone name.
- name
Servers List<String> - List of DNS name servers for the Hosted Zone.
- primary
Name StringServer - The Route 53 name server that created the SOA record.
- resource
Record NumberSet Count - The number of Record Set in the Hosted Zone.
- Map<String>
- A map of tags assigned to the Hosted Zone.
- vpc
Id String - zone
Id String - The Hosted Zone identifier.
- private
Zone Boolean - Indicates whether this is a private hosted zone.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
aws
Terraform Provider.