AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.10.0 published on Monday, Jul 11, 2022 by Pulumi

getHostedZoneId

Deprecated:

aws.elasticloadbalancing.getHostedZoneId has been deprecated in favor of aws.elb.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
        {
            ZoneId = aws_route53_zone.Primary.Zone_id,
            Name = "example.com",
            Type = "A",
            Aliases = 
            {
                new Aws.Route53.Inputs.RecordAliasArgs
                {
                    Name = aws_elb.Main.Dns_name,
                    ZoneId = main.Apply(main => main.Id),
                    EvaluateTargetHealth = true,
                },
            },
        });
    }

}
package main

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

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var main = Output.of(ElbFunctions.getHostedZoneId());

        var www = new Record("www", RecordArgs.builder()        
            .zoneId(aws_route53_zone.primary().zone_id())
            .name("example.com")
            .type("A")
            .aliases(RecordAliasArgs.builder()
                .name(aws_elb.main().dns_name())
                .zoneId(main.apply(getHostedZoneIdResult -> getHostedZoneIdResult.id()))
                .evaluateTargetHealth(true)
                .build())
            .build());

    }
}
import pulumi
import pulumi_aws as aws

main = aws.elb.get_hosted_zone_id()
www = aws.route53.Record("www",
    zone_id=aws_route53_zone["primary"]["zone_id"],
    name="example.com",
    type="A",
    aliases=[aws.route53.RecordAliasArgs(
        name=aws_elb["main"]["dns_name"],
        zone_id=main.id,
        evaluate_target_health=True,
    )])
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: aws_route53_zone.primary.zone_id,
    name: "example.com",
    type: "A",
    aliases: [{
        name: aws_elb.main.dns_name,
        zoneId: main.then(main => main.id),
        evaluateTargetHealth: true,
    }],
});
resources:
  www:
    type: aws:route53:Record
    properties:
      zoneId: ${aws_route53_zone.primary.zone_id}
      name: example.com
      type: A
      aliases:
        - name: ${aws_elb.main.dns_name}
          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:elasticloadbalancing/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:

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 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
id String

The provider-assigned unique ID for this managed resource.

region String

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.