GetHostedZoneId

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

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var main = Output.Create(Aws.Elb.GetHostedZoneId.InvokeAsync());
        var www = new Aws.Route53.Record("www", new Aws.Route53.RecordArgs
        {
            Aliases = 
            {
                new Aws.Route53.Inputs.RecordAliasArgs
                {
                    EvaluateTargetHealth = true,
                    Name = aws_elb.Main.Dns_name,
                    ZoneId = main.Apply(main => main.Id),
                },
            },
            Name = "example.com",
            Type = "A",
            ZoneId = aws_route53_zone.Primary.Zone_id,
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/elb"
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/route53"
    "github.com/pulumi/pulumi/sdk/v2/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{
            Aliases: route53.RecordAliasArray{
                &route53.RecordAliasArgs{
                    EvaluateTargetHealth: pulumi.Bool(true),
                    Name:                 pulumi.String(aws_elb.Main.Dns_name),
                    ZoneId:               pulumi.String(main.Id),
                },
            },
            Name:   pulumi.String("example.com"),
            Type:   pulumi.String("A"),
            ZoneId: pulumi.String(aws_route53_zone.Primary.Zone_id),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

main = aws.elb.get_hosted_zone_id()
www = aws.route53.Record("www",
    aliases=[{
        "evaluateTargetHealth": True,
        "name": aws_elb["main"]["dns_name"],
        "zone_id": main.id,
    }],
    name="example.com",
    type="A",
    zone_id=aws_route53_zone["primary"]["zone_id"])
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const main = pulumi.output(aws.elb.getHostedZoneId({ async: true }));
const www = new aws.route53.Record("www", {
    aliases: [{
        evaluateTargetHealth: true,
        name: aws_elb_main.dnsName,
        zoneId: main.id,
    }],
    name: "example.com",
    type: "A",
    zoneId: aws_route53_zone_primary.zoneId,
});

Deprecated: aws.elasticloadbalancing.getHostedZoneId has been deprecated in favor of aws.elb.getHostedZoneId

Using GetHostedZoneId

function getHostedZoneId(args: GetHostedZoneIdArgs, opts?: InvokeOptions): Promise<GetHostedZoneIdResult>
function  get_hosted_zone_id(region=None, opts=None)
func GetHostedZoneId(ctx *Context, args *GetHostedZoneIdArgs, opts ...InvokeOption) (*GetHostedZoneIdResult, error)
public static class GetHostedZoneId {
    public static Task<GetHostedZoneIdResult> InvokeAsync(GetHostedZoneIdArgs args, InvokeOptions? opts = null)
}

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 str

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:

Id string

The provider-assigned unique ID for this managed resource.

Region string
Id string

The provider-assigned unique ID for this managed resource.

Region string
id string

The provider-assigned unique ID for this managed resource.

region string
id str

The provider-assigned unique ID for this managed resource.

region str

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.