1. Packages
  2. AWS
  3. API Docs
  4. apprunner
  5. getHostedZoneId
AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi

aws.apprunner.getHostedZoneId

Explore with Pulumi AI

aws logo
AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi

    Use this data source to get the HostedZoneId of an AWS App Runner service deployed in a given region for the purpose of using it in an AWS Route53 Alias record.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const main = aws.apprunner.getHostedZoneId({});
    const www = new aws.route53.Record("www", {
        zoneId: primary.zoneId,
        name: "example.com",
        type: aws.route53.RecordType.A,
        aliases: [{
            name: mainAwsApprunnerCustomDomainAssociation.dnsTarget,
            zoneId: main.then(main => main.id),
            evaluateTargetHealth: true,
        }],
    });
    
    import pulumi
    import pulumi_aws as aws
    
    main = aws.apprunner.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_apprunner_custom_domain_association["dnsTarget"],
            "zone_id": main.id,
            "evaluate_target_health": True,
        }])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apprunner"
    	"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 := apprunner.GetHostedZoneId(ctx, &apprunner.GetHostedZoneIdArgs{}, 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(mainAwsApprunnerCustomDomainAssociation.DnsTarget),
    					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.AppRunner.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 = mainAwsApprunnerCustomDomainAssociation.DnsTarget,
                    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.apprunner.ApprunnerFunctions;
    import com.pulumi.aws.apprunner.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 = ApprunnerFunctions.getHostedZoneId();
    
            var www = new Record("www", RecordArgs.builder()
                .zoneId(primary.zoneId())
                .name("example.com")
                .type("A")
                .aliases(RecordAliasArgs.builder()
                    .name(mainAwsApprunnerCustomDomainAssociation.dnsTarget())
                    .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: ${mainAwsApprunnerCustomDomainAssociation.dnsTarget}
              zoneId: ${main.id}
              evaluateTargetHealth: true
    variables:
      main:
        fn::invoke:
          Function: aws:apprunner: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:apprunner/getHostedZoneId:getHostedZoneId
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Region string
    Name of the region whose AWS App Runner service HostedZoneId is desired. Defaults to the region from the AWS provider configuration.
    Region string
    Name of the region whose AWS App Runner service HostedZoneId is desired. Defaults to the region from the AWS provider configuration.
    region String
    Name of the region whose AWS App Runner service HostedZoneId is desired. Defaults to the region from the AWS provider configuration.
    region string
    Name of the region whose AWS App Runner service HostedZoneId is desired. Defaults to the region from the AWS provider configuration.
    region str
    Name of the region whose AWS App Runner service HostedZoneId is desired. Defaults to the region from the AWS provider configuration.
    region String
    Name of the region whose AWS App Runner service HostedZoneId is desired. Defaults to the region from the AWS provider configuration.

    getHostedZoneId Result

    The following output properties are available:

    Id string
    ID of the AWS App Runner service HostedZoneId in the selected region.
    Region string
    Id string
    ID of the AWS App Runner service HostedZoneId in the selected region.
    Region string
    id String
    ID of the AWS App Runner service HostedZoneId in the selected region.
    region String
    id string
    ID of the AWS App Runner service HostedZoneId in the selected region.
    region string
    id str
    ID of the AWS App Runner service HostedZoneId in the selected region.
    region str
    id String
    ID of the AWS App Runner service HostedZoneId in the selected region.
    region String

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo
    AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi