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 System.Collections.Generic;
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 = aws_route53_zone.Primary.Zone_id,
Name = "example.com",
Type = "A",
Aliases = new[]
{
new Aws.Route53.Inputs.RecordAliasArgs
{
Name = aws_elb.Main.Dns_name,
ZoneId = main.Apply(getHostedZoneIdResult => getHostedZoneIdResult.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 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(aws_route53_zone.primary().zone_id())
.name("example.com")
.type("A")
.aliases(RecordAliasArgs.builder()
.name(aws_elb.main().dns_name())
.zoneId(main.applyValue(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: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.