Try AWS Native preview for resources not in the classic version.
aws.elb.getHostedZoneId
Explore with Pulumi AI
Try AWS Native preview for resources not in the classic version.
Use this data source to get the HostedZoneId of the AWS Elastic Load Balancing HostedZoneId in a given region for the purpose of using in an AWS Route53 Alias.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const main = aws.elb.getHostedZoneId({});
const www = new aws.route53.Record("www", {
zoneId: primary.zoneId,
name: "example.com",
type: aws.route53.RecordType.A,
aliases: [{
name: mainAwsElb.dnsName,
zoneId: main.then(main => main.id),
evaluateTargetHealth: true,
}],
});
import pulumi
import pulumi_aws as aws
main = aws.elb.get_hosted_zone_id()
www = aws.route53.Record("www",
zone_id=primary["zoneId"],
name="example.com",
type=aws.route53.RecordType.A,
aliases=[{
"name": main_aws_elb["dnsName"],
"zoneId": main.id,
"evaluateTargetHealth": True,
}])
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/elb"
"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 {
main, err := elb.GetHostedZoneId(ctx, nil, nil)
if err != nil {
return err
}
_, err = route53.NewRecord(ctx, "www", &route53.RecordArgs{
ZoneId: pulumi.Any(primary.ZoneId),
Name: pulumi.String("example.com"),
Type: pulumi.String(route53.RecordTypeA),
Aliases: route53.RecordAliasArray{
&route53.RecordAliasArgs{
Name: pulumi.Any(mainAwsElb.DnsName),
ZoneId: pulumi.String(main.Id),
EvaluateTargetHealth: pulumi.Bool(true),
},
},
})
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 main = Aws.Elb.GetHostedZoneId.Invoke();
var www = new Aws.Route53.Record("www", new()
{
ZoneId = primary.ZoneId,
Name = "example.com",
Type = Aws.Route53.RecordType.A,
Aliases = new[]
{
new Aws.Route53.Inputs.RecordAliasArgs
{
Name = mainAwsElb.DnsName,
ZoneId = main.Apply(getHostedZoneIdResult => getHostedZoneIdResult.Id),
EvaluateTargetHealth = true,
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.elb.ElbFunctions;
import com.pulumi.aws.elb.inputs.GetHostedZoneIdArgs;
import com.pulumi.aws.route53.Record;
import com.pulumi.aws.route53.RecordArgs;
import com.pulumi.aws.route53.inputs.RecordAliasArgs;
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 main = ElbFunctions.getHostedZoneId();
var www = new Record("www", RecordArgs.builder()
.zoneId(primary.zoneId())
.name("example.com")
.type("A")
.aliases(RecordAliasArgs.builder()
.name(mainAwsElb.dnsName())
.zoneId(main.applyValue(getHostedZoneIdResult -> getHostedZoneIdResult.id()))
.evaluateTargetHealth(true)
.build())
.build());
}
}
resources:
www:
type: aws:route53:Record
properties:
zoneId: ${primary.zoneId}
name: example.com
type: A
aliases:
- name: ${mainAwsElb.dnsName}
zoneId: ${main.id}
evaluateTargetHealth: true
variables:
main:
fn::invoke:
Function: aws:elb:getHostedZoneId
Arguments: {}
Using getHostedZoneId
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 getHostedZoneId(args: GetHostedZoneIdArgs, opts?: InvokeOptions): Promise<GetHostedZoneIdResult>
function getHostedZoneIdOutput(args: GetHostedZoneIdOutputArgs, opts?: InvokeOptions): Output<GetHostedZoneIdResult>
def get_hosted_zone_id(region: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetHostedZoneIdResult
def get_hosted_zone_id_output(region: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetHostedZoneIdResult]
func GetHostedZoneId(ctx *Context, args *GetHostedZoneIdArgs, opts ...InvokeOption) (*GetHostedZoneIdResult, error)
func GetHostedZoneIdOutput(ctx *Context, args *GetHostedZoneIdOutputArgs, opts ...InvokeOption) GetHostedZoneIdResultOutput
> Note: This function is named GetHostedZoneId
in the Go SDK.
public static class GetHostedZoneId
{
public static Task<GetHostedZoneIdResult> InvokeAsync(GetHostedZoneIdArgs args, InvokeOptions? opts = null)
public static Output<GetHostedZoneIdResult> Invoke(GetHostedZoneIdInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetHostedZoneIdResult> getHostedZoneId(GetHostedZoneIdArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: aws:elb/getHostedZoneId:getHostedZoneId
arguments:
# arguments dictionary
The following arguments are supported:
- Region string
- Name of the region whose AWS ELB HostedZoneId is desired. Defaults to the region from the AWS provider configuration.
- Region string
- Name of the region whose AWS ELB HostedZoneId is desired. Defaults to the region from the AWS provider configuration.
- region String
- Name of the region whose AWS ELB HostedZoneId is desired. Defaults to the region from the AWS provider configuration.
- region string
- Name of the region whose AWS ELB HostedZoneId is desired. Defaults to the region from the AWS provider configuration.
- region str
- Name of the region whose AWS ELB HostedZoneId is desired. Defaults to the region from the AWS provider configuration.
- region String
- Name of the region whose AWS ELB HostedZoneId is desired. Defaults to the region from the AWS provider configuration.
getHostedZoneId Result
The following output properties are available:
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
aws
Terraform Provider.
Try AWS Native preview for resources not in the classic version.