1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. compute
  5. getAddress
Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 by Pulumi

gcp.compute.getAddress

Explore with Pulumi AI

gcp logo
Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 by Pulumi

    Get the IP address from a static address. For more information see the official API documentation.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const myAddress = gcp.compute.getAddress({
        name: "foobar",
    });
    const prod = new gcp.dns.ManagedZone("prod", {
        name: "prod-zone",
        dnsName: "prod.mydomain.com.",
    });
    const frontend = new gcp.dns.RecordSet("frontend", {
        name: pulumi.interpolate`frontend.${prod.dnsName}`,
        type: "A",
        ttl: 300,
        managedZone: prod.name,
        rrdatas: [myAddress.then(myAddress => myAddress.address)],
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    my_address = gcp.compute.get_address(name="foobar")
    prod = gcp.dns.ManagedZone("prod",
        name="prod-zone",
        dns_name="prod.mydomain.com.")
    frontend = gcp.dns.RecordSet("frontend",
        name=prod.dns_name.apply(lambda dns_name: f"frontend.{dns_name}"),
        type="A",
        ttl=300,
        managed_zone=prod.name,
        rrdatas=[my_address.address])
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
    	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/dns"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		myAddress, err := compute.LookupAddress(ctx, &compute.LookupAddressArgs{
    			Name: "foobar",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		prod, err := dns.NewManagedZone(ctx, "prod", &dns.ManagedZoneArgs{
    			Name:    pulumi.String("prod-zone"),
    			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("frontend.%v", 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
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var myAddress = Gcp.Compute.GetAddress.Invoke(new()
        {
            Name = "foobar",
        });
    
        var prod = new Gcp.Dns.ManagedZone("prod", new()
        {
            Name = "prod-zone",
            DnsName = "prod.mydomain.com.",
        });
    
        var frontend = new Gcp.Dns.RecordSet("frontend", new()
        {
            Name = prod.DnsName.Apply(dnsName => $"frontend.{dnsName}"),
            Type = "A",
            Ttl = 300,
            ManagedZone = prod.Name,
            Rrdatas = new[]
            {
                myAddress.Apply(getAddressResult => getAddressResult.Address),
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.compute.ComputeFunctions;
    import com.pulumi.gcp.compute.inputs.GetAddressArgs;
    import com.pulumi.gcp.dns.ManagedZone;
    import com.pulumi.gcp.dns.ManagedZoneArgs;
    import com.pulumi.gcp.dns.RecordSet;
    import com.pulumi.gcp.dns.RecordSetArgs;
    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 myAddress = ComputeFunctions.getAddress(GetAddressArgs.builder()
                .name("foobar")
                .build());
    
            var prod = new ManagedZone("prod", ManagedZoneArgs.builder()
                .name("prod-zone")
                .dnsName("prod.mydomain.com.")
                .build());
    
            var frontend = new RecordSet("frontend", RecordSetArgs.builder()
                .name(prod.dnsName().applyValue(dnsName -> String.format("frontend.%s", dnsName)))
                .type("A")
                .ttl(300)
                .managedZone(prod.name())
                .rrdatas(myAddress.applyValue(getAddressResult -> getAddressResult.address()))
                .build());
    
        }
    }
    
    resources:
      frontend:
        type: gcp:dns:RecordSet
        properties:
          name: frontend.${prod.dnsName}
          type: A
          ttl: 300
          managedZone: ${prod.name}
          rrdatas:
            - ${myAddress.address}
      prod:
        type: gcp:dns:ManagedZone
        properties:
          name: prod-zone
          dnsName: prod.mydomain.com.
    variables:
      myAddress:
        fn::invoke:
          Function: gcp:compute:getAddress
          Arguments:
            name: foobar
    

    Using getAddress

    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 getAddress(args: GetAddressArgs, opts?: InvokeOptions): Promise<GetAddressResult>
    function getAddressOutput(args: GetAddressOutputArgs, opts?: InvokeOptions): Output<GetAddressResult>
    def get_address(name: Optional[str] = None,
                    project: Optional[str] = None,
                    region: Optional[str] = None,
                    opts: Optional[InvokeOptions] = None) -> GetAddressResult
    def get_address_output(name: Optional[pulumi.Input[str]] = None,
                    project: Optional[pulumi.Input[str]] = None,
                    region: Optional[pulumi.Input[str]] = None,
                    opts: Optional[InvokeOptions] = None) -> Output[GetAddressResult]
    func LookupAddress(ctx *Context, args *LookupAddressArgs, opts ...InvokeOption) (*LookupAddressResult, error)
    func LookupAddressOutput(ctx *Context, args *LookupAddressOutputArgs, opts ...InvokeOption) LookupAddressResultOutput

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

    public static class GetAddress 
    {
        public static Task<GetAddressResult> InvokeAsync(GetAddressArgs args, InvokeOptions? opts = null)
        public static Output<GetAddressResult> Invoke(GetAddressInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetAddressResult> getAddress(GetAddressArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: gcp:compute/getAddress:getAddress
      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.
    Region string
    The Region in which the created address reside. If it is not provided, the provider region 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.
    Region string
    The Region in which the created address reside. If it is not provided, the provider region 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.
    region String
    The Region in which the created address reside. If it is not provided, the provider region 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.
    region string
    The Region in which the created address reside. If it is not provided, the provider region 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.
    region str
    The Region in which the created address reside. If it is not provided, the provider region 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.
    region String
    The Region in which the created address reside. If it is not provided, the provider region is used.

    getAddress Result

    The following output properties are available:

    Address string
    The IP of the created resource.
    AddressType string
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    Network string
    NetworkTier string
    PrefixLength int
    Project string
    Purpose string
    Region string
    SelfLink string
    The URI of the created resource.
    Status string
    Indicates if the address is used. Possible values are: RESERVED or IN_USE.
    Subnetwork string
    Users string
    Address string
    The IP of the created resource.
    AddressType string
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    Network string
    NetworkTier string
    PrefixLength int
    Project string
    Purpose string
    Region string
    SelfLink string
    The URI of the created resource.
    Status string
    Indicates if the address is used. Possible values are: RESERVED or IN_USE.
    Subnetwork string
    Users string
    address String
    The IP of the created resource.
    addressType String
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    network String
    networkTier String
    prefixLength Integer
    project String
    purpose String
    region String
    selfLink String
    The URI of the created resource.
    status String
    Indicates if the address is used. Possible values are: RESERVED or IN_USE.
    subnetwork String
    users String
    address string
    The IP of the created resource.
    addressType string
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    network string
    networkTier string
    prefixLength number
    project string
    purpose string
    region string
    selfLink string
    The URI of the created resource.
    status string
    Indicates if the address is used. Possible values are: RESERVED or IN_USE.
    subnetwork string
    users string
    address str
    The IP of the created resource.
    address_type str
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    network str
    network_tier str
    prefix_length int
    project str
    purpose str
    region 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.
    subnetwork str
    users str
    address String
    The IP of the created resource.
    addressType String
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    network String
    networkTier String
    prefixLength Number
    project String
    purpose String
    region String
    selfLink String
    The URI of the created resource.
    status String
    Indicates if the address is used. Possible values are: RESERVED or IN_USE.
    subnetwork String
    users String

    Package Details

    Repository
    Google Cloud (GCP) Classic pulumi/pulumi-gcp
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the google-beta Terraform Provider.
    gcp logo
    Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 by Pulumi