github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/lb/getHostedZoneId.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package lb 5 6 import ( 7 "context" 8 "reflect" 9 10 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 11 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 ) 13 14 // Use this data source to get the HostedZoneId of the AWS Elastic Load Balancing (ELB) in a given region for the purpose of using in an AWS Route53 Alias. Specify the ELB type (`network` or `application`) to return the relevant the associated HostedZoneId. Ref: [ELB service endpoints](https://docs.aws.amazon.com/general/latest/gr/elb.html#elb_region) 15 // 16 // ## Example Usage 17 // 18 // <!--Start PulumiCodeChooser --> 19 // ```go 20 // package main 21 // 22 // import ( 23 // 24 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lb" 25 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/route53" 26 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 27 // 28 // ) 29 // 30 // func main() { 31 // pulumi.Run(func(ctx *pulumi.Context) error { 32 // main, err := lb.GetHostedZoneId(ctx, nil, nil) 33 // if err != nil { 34 // return err 35 // } 36 // _, err = route53.NewRecord(ctx, "www", &route53.RecordArgs{ 37 // ZoneId: pulumi.Any(primary.ZoneId), 38 // Name: pulumi.String("example.com"), 39 // Type: pulumi.String(route53.RecordTypeA), 40 // Aliases: route53.RecordAliasArray{ 41 // &route53.RecordAliasArgs{ 42 // Name: pulumi.Any(mainAwsLb.DnsName), 43 // ZoneId: pulumi.String(main.Id), 44 // EvaluateTargetHealth: pulumi.Bool(true), 45 // }, 46 // }, 47 // }) 48 // if err != nil { 49 // return err 50 // } 51 // return nil 52 // }) 53 // } 54 // 55 // ``` 56 // <!--End PulumiCodeChooser --> 57 func GetHostedZoneId(ctx *pulumi.Context, args *GetHostedZoneIdArgs, opts ...pulumi.InvokeOption) (*GetHostedZoneIdResult, error) { 58 opts = internal.PkgInvokeDefaultOpts(opts) 59 var rv GetHostedZoneIdResult 60 err := ctx.Invoke("aws:lb/getHostedZoneId:getHostedZoneId", args, &rv, opts...) 61 if err != nil { 62 return nil, err 63 } 64 return &rv, nil 65 } 66 67 // A collection of arguments for invoking getHostedZoneId. 68 type GetHostedZoneIdArgs struct { 69 // Type of load balancer to create. Possible values are `application` or `network`. The default value is `application`. 70 LoadBalancerType *string `pulumi:"loadBalancerType"` 71 // Name of the region whose AWS ELB HostedZoneId is desired. 72 // Defaults to the region from the AWS provider configuration. 73 Region *string `pulumi:"region"` 74 } 75 76 // A collection of values returned by getHostedZoneId. 77 type GetHostedZoneIdResult struct { 78 // The provider-assigned unique ID for this managed resource. 79 Id string `pulumi:"id"` 80 LoadBalancerType *string `pulumi:"loadBalancerType"` 81 Region *string `pulumi:"region"` 82 } 83 84 func GetHostedZoneIdOutput(ctx *pulumi.Context, args GetHostedZoneIdOutputArgs, opts ...pulumi.InvokeOption) GetHostedZoneIdResultOutput { 85 return pulumi.ToOutputWithContext(context.Background(), args). 86 ApplyT(func(v interface{}) (GetHostedZoneIdResult, error) { 87 args := v.(GetHostedZoneIdArgs) 88 r, err := GetHostedZoneId(ctx, &args, opts...) 89 var s GetHostedZoneIdResult 90 if r != nil { 91 s = *r 92 } 93 return s, err 94 }).(GetHostedZoneIdResultOutput) 95 } 96 97 // A collection of arguments for invoking getHostedZoneId. 98 type GetHostedZoneIdOutputArgs struct { 99 // Type of load balancer to create. Possible values are `application` or `network`. The default value is `application`. 100 LoadBalancerType pulumi.StringPtrInput `pulumi:"loadBalancerType"` 101 // Name of the region whose AWS ELB HostedZoneId is desired. 102 // Defaults to the region from the AWS provider configuration. 103 Region pulumi.StringPtrInput `pulumi:"region"` 104 } 105 106 func (GetHostedZoneIdOutputArgs) ElementType() reflect.Type { 107 return reflect.TypeOf((*GetHostedZoneIdArgs)(nil)).Elem() 108 } 109 110 // A collection of values returned by getHostedZoneId. 111 type GetHostedZoneIdResultOutput struct{ *pulumi.OutputState } 112 113 func (GetHostedZoneIdResultOutput) ElementType() reflect.Type { 114 return reflect.TypeOf((*GetHostedZoneIdResult)(nil)).Elem() 115 } 116 117 func (o GetHostedZoneIdResultOutput) ToGetHostedZoneIdResultOutput() GetHostedZoneIdResultOutput { 118 return o 119 } 120 121 func (o GetHostedZoneIdResultOutput) ToGetHostedZoneIdResultOutputWithContext(ctx context.Context) GetHostedZoneIdResultOutput { 122 return o 123 } 124 125 // The provider-assigned unique ID for this managed resource. 126 func (o GetHostedZoneIdResultOutput) Id() pulumi.StringOutput { 127 return o.ApplyT(func(v GetHostedZoneIdResult) string { return v.Id }).(pulumi.StringOutput) 128 } 129 130 func (o GetHostedZoneIdResultOutput) LoadBalancerType() pulumi.StringPtrOutput { 131 return o.ApplyT(func(v GetHostedZoneIdResult) *string { return v.LoadBalancerType }).(pulumi.StringPtrOutput) 132 } 133 134 func (o GetHostedZoneIdResultOutput) Region() pulumi.StringPtrOutput { 135 return o.ApplyT(func(v GetHostedZoneIdResult) *string { return v.Region }).(pulumi.StringPtrOutput) 136 } 137 138 func init() { 139 pulumi.RegisterOutputType(GetHostedZoneIdResultOutput{}) 140 }