Google Cloud (GCP) Classic

Pulumi Official
Package maintained by Pulumi
v6.32.0 published on Wednesday, Jul 20, 2022 by Pulumi

getGlobalAddress

Get the IP address from a static address reserved for a Global Forwarding Rule which are only used for HTTP load balancing. For more information see the official API documentation.

Example Usage

using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
    public MyStack()
    {
        var myAddress = Output.Create(Gcp.Compute.GetGlobalAddress.InvokeAsync(new Gcp.Compute.GetGlobalAddressArgs
        {
            Name = "foobar",
        }));
        var prod = new Gcp.Dns.ManagedZone("prod", new Gcp.Dns.ManagedZoneArgs
        {
            DnsName = "prod.mydomain.com.",
        });
        var frontend = new Gcp.Dns.RecordSet("frontend", new Gcp.Dns.RecordSetArgs
        {
            Name = prod.DnsName.Apply(dnsName => $"lb.{dnsName}"),
            Type = "A",
            Ttl = 300,
            ManagedZone = prod.Name,
            Rrdatas = 
            {
                myAddress.Apply(myAddress => myAddress.Address),
            },
        });
    }

}
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/compute"
	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/dns"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		myAddress, err := compute.LookupGlobalAddress(ctx, &compute.LookupGlobalAddressArgs{
			Name: "foobar",
		}, nil)
		if err != nil {
			return err
		}
		prod, err := dns.NewManagedZone(ctx, "prod", &dns.ManagedZoneArgs{
			DnsName: pulumi.String("prod.mydomain.com."),
		})
		if err != nil {
			return err
		}
		_, err = dns.NewRecordSet(ctx, "frontend", &dns.RecordSetArgs{
			Name: prod.DnsName.ApplyT(func(dnsName string) (string, error) {
				return fmt.Sprintf("%v%v", "lb.", dnsName), nil
			}).(pulumi.StringOutput),
			Type:        pulumi.String("A"),
			Ttl:         pulumi.Int(300),
			ManagedZone: prod.Name,
			Rrdatas: pulumi.StringArray{
				pulumi.String(myAddress.Address),
			},
		})
		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 myAddress = Output.of(ComputeFunctions.getGlobalAddress(GetGlobalAddressArgs.builder()
            .name("foobar")
            .build()));

        var prod = new ManagedZone("prod", ManagedZoneArgs.builder()        
            .dnsName("prod.mydomain.com.")
            .build());

        var frontend = new RecordSet("frontend", RecordSetArgs.builder()        
            .name(prod.dnsName().apply(dnsName -> String.format("lb.%s", dnsName)))
            .type("A")
            .ttl(300)
            .managedZone(prod.name())
            .rrdatas(myAddress.apply(getGlobalAddressResult -> getGlobalAddressResult.address()))
            .build());

    }
}
import pulumi
import pulumi_gcp as gcp

my_address = gcp.compute.get_global_address(name="foobar")
prod = gcp.dns.ManagedZone("prod", dns_name="prod.mydomain.com.")
frontend = gcp.dns.RecordSet("frontend",
    name=prod.dns_name.apply(lambda dns_name: f"lb.{dns_name}"),
    type="A",
    ttl=300,
    managed_zone=prod.name,
    rrdatas=[my_address.address])
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const myAddress = gcp.compute.getGlobalAddress({
    name: "foobar",
});
const prod = new gcp.dns.ManagedZone("prod", {dnsName: "prod.mydomain.com."});
const frontend = new gcp.dns.RecordSet("frontend", {
    name: pulumi.interpolate`lb.${prod.dnsName}`,
    type: "A",
    ttl: 300,
    managedZone: prod.name,
    rrdatas: [myAddress.then(myAddress => myAddress.address)],
});
resources:
  frontend:
    type: gcp:dns:RecordSet
    properties:
      name: lb.${prod.dnsName}
      type: A
      ttl: 300
      managedZone: ${prod.name}
      rrdatas:
        - ${myAddress.address}
  prod:
    type: gcp:dns:ManagedZone
    properties:
      dnsName: prod.mydomain.com.
variables:
  myAddress:
    Fn::Invoke:
      Function: gcp:compute:getGlobalAddress
      Arguments:
        name: foobar

Using getGlobalAddress

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 getGlobalAddress(args: GetGlobalAddressArgs, opts?: InvokeOptions): Promise<GetGlobalAddressResult>
function getGlobalAddressOutput(args: GetGlobalAddressOutputArgs, opts?: InvokeOptions): Output<GetGlobalAddressResult>
def get_global_address(name: Optional[str] = None,
                       project: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetGlobalAddressResult
def get_global_address_output(name: Optional[pulumi.Input[str]] = None,
                       project: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetGlobalAddressResult]
func LookupGlobalAddress(ctx *Context, args *LookupGlobalAddressArgs, opts ...InvokeOption) (*LookupGlobalAddressResult, error)
func LookupGlobalAddressOutput(ctx *Context, args *LookupGlobalAddressOutputArgs, opts ...InvokeOption) LookupGlobalAddressResultOutput

> Note: This function is named LookupGlobalAddress in the Go SDK.

public static class GetGlobalAddress 
{
    public static Task<GetGlobalAddressResult> InvokeAsync(GetGlobalAddressArgs args, InvokeOptions? opts = null)
    public static Output<GetGlobalAddressResult> Invoke(GetGlobalAddressInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetGlobalAddressResult> getGlobalAddress(GetGlobalAddressArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: gcp:compute/getGlobalAddress:getGlobalAddress
  Arguments:
    # Arguments dictionary

The following arguments are supported:

Name string

A unique name for the resource, required by GCE.

Project string

The project in which the resource belongs. If it is not provided, the provider project is used.

Name string

A unique name for the resource, required by GCE.

Project string

The project in which the resource belongs. If it is not provided, the provider project is used.

name String

A unique name for the resource, required by GCE.

project String

The project in which the resource belongs. If it is not provided, the provider project is used.

name string

A unique name for the resource, required by GCE.

project string

The project in which the resource belongs. If it is not provided, the provider project is used.

name str

A unique name for the resource, required by GCE.

project str

The project in which the resource belongs. If it is not provided, the provider project is used.

name String

A unique name for the resource, required by GCE.

project String

The project in which the resource belongs. If it is not provided, the provider project is used.

getGlobalAddress Result

The following output properties are available:

Address string

The IP of the created resource.

Id string

The provider-assigned unique ID for this managed resource.

Name string
Project string
SelfLink string

The URI of the created resource.

Status string

Indicates if the address is used. Possible values are: RESERVED or IN_USE.

Address string

The IP of the created resource.

Id string

The provider-assigned unique ID for this managed resource.

Name string
Project string
SelfLink string

The URI of the created resource.

Status string

Indicates if the address is used. Possible values are: RESERVED or IN_USE.

address String

The IP of the created resource.

id String

The provider-assigned unique ID for this managed resource.

name String
project String
selfLink String

The URI of the created resource.

status String

Indicates if the address is used. Possible values are: RESERVED or IN_USE.

address string

The IP of the created resource.

id string

The provider-assigned unique ID for this managed resource.

name string
project string
selfLink string

The URI of the created resource.

status string

Indicates if the address is used. Possible values are: RESERVED or IN_USE.

address str

The IP of the created resource.

id str

The provider-assigned unique ID for this managed resource.

name str
project str
self_link str

The URI of the created resource.

status str

Indicates if the address is used. Possible values are: RESERVED or IN_USE.

address String

The IP of the created resource.

id String

The provider-assigned unique ID for this managed resource.

name String
project String
selfLink String

The URI of the created resource.

status String

Indicates if the address is used. Possible values are: RESERVED or IN_USE.

Package Details

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

This Pulumi package is based on the google-beta Terraform Provider.