1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. artifactregistry
  5. getLocations
Google Cloud Classic v8.3.1 published on Wednesday, Sep 25, 2024 by Pulumi

gcp.artifactregistry.getLocations

Explore with Pulumi AI

gcp logo
Google Cloud Classic v8.3.1 published on Wednesday, Sep 25, 2024 by Pulumi

    Get Artifact Registry locations available for a project.

    To get more information about Artifact Registry, see:

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const available = gcp.artifactregistry.getLocations({});
    
    import pulumi
    import pulumi_gcp as gcp
    
    available = gcp.artifactregistry.get_locations()
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/artifactregistry"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := artifactregistry.GetLocations(ctx, nil, nil)
    		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 available = Gcp.ArtifactRegistry.GetLocations.Invoke();
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.artifactregistry.ArtifactregistryFunctions;
    import com.pulumi.gcp.artifactregistry.inputs.GetLocationsArgs;
    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 available = ArtifactregistryFunctions.getLocations();
    
        }
    }
    
    variables:
      available:
        fn::invoke:
          Function: gcp:artifactregistry:getLocations
          Arguments: {}
    

    Multi-Regional Artifact Registry Deployment

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const available = gcp.artifactregistry.getLocations({});
    const repoOne = new gcp.artifactregistry.Repository("repo_one", {
        location: available.then(available => available.locations?.[0]),
        repositoryId: "repo-one",
        format: "apt",
    });
    const repoTwo = new gcp.artifactregistry.Repository("repo_two", {
        location: available.then(available => available.locations?.[1]),
        repositoryId: "repo-two",
        format: "apt",
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    available = gcp.artifactregistry.get_locations()
    repo_one = gcp.artifactregistry.Repository("repo_one",
        location=available.locations[0],
        repository_id="repo-one",
        format="apt")
    repo_two = gcp.artifactregistry.Repository("repo_two",
        location=available.locations[1],
        repository_id="repo-two",
        format="apt")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/artifactregistry"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		available, err := artifactregistry.GetLocations(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		_, err = artifactregistry.NewRepository(ctx, "repo_one", &artifactregistry.RepositoryArgs{
    			Location:     pulumi.String(available.Locations[0]),
    			RepositoryId: pulumi.String("repo-one"),
    			Format:       pulumi.String("apt"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = artifactregistry.NewRepository(ctx, "repo_two", &artifactregistry.RepositoryArgs{
    			Location:     pulumi.String(available.Locations[1]),
    			RepositoryId: pulumi.String("repo-two"),
    			Format:       pulumi.String("apt"),
    		})
    		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 available = Gcp.ArtifactRegistry.GetLocations.Invoke();
    
        var repoOne = new Gcp.ArtifactRegistry.Repository("repo_one", new()
        {
            Location = available.Apply(getLocationsResult => getLocationsResult.Locations[0]),
            RepositoryId = "repo-one",
            Format = "apt",
        });
    
        var repoTwo = new Gcp.ArtifactRegistry.Repository("repo_two", new()
        {
            Location = available.Apply(getLocationsResult => getLocationsResult.Locations[1]),
            RepositoryId = "repo-two",
            Format = "apt",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.artifactregistry.ArtifactregistryFunctions;
    import com.pulumi.gcp.artifactregistry.inputs.GetLocationsArgs;
    import com.pulumi.gcp.artifactregistry.Repository;
    import com.pulumi.gcp.artifactregistry.RepositoryArgs;
    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 available = ArtifactregistryFunctions.getLocations();
    
            var repoOne = new Repository("repoOne", RepositoryArgs.builder()
                .location(available.applyValue(getLocationsResult -> getLocationsResult.locations()[0]))
                .repositoryId("repo-one")
                .format("apt")
                .build());
    
            var repoTwo = new Repository("repoTwo", RepositoryArgs.builder()
                .location(available.applyValue(getLocationsResult -> getLocationsResult.locations()[1]))
                .repositoryId("repo-two")
                .format("apt")
                .build());
    
        }
    }
    
    resources:
      repoOne:
        type: gcp:artifactregistry:Repository
        name: repo_one
        properties:
          location: ${available.locations[0]}
          repositoryId: repo-one
          format: apt
      repoTwo:
        type: gcp:artifactregistry:Repository
        name: repo_two
        properties:
          location: ${available.locations[1]}
          repositoryId: repo-two
          format: apt
    variables:
      available:
        fn::invoke:
          Function: gcp:artifactregistry:getLocations
          Arguments: {}
    

    Using getLocations

    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 getLocations(args: GetLocationsArgs, opts?: InvokeOptions): Promise<GetLocationsResult>
    function getLocationsOutput(args: GetLocationsOutputArgs, opts?: InvokeOptions): Output<GetLocationsResult>
    def get_locations(project: Optional[str] = None,
                      opts: Optional[InvokeOptions] = None) -> GetLocationsResult
    def get_locations_output(project: Optional[pulumi.Input[str]] = None,
                      opts: Optional[InvokeOptions] = None) -> Output[GetLocationsResult]
    func GetLocations(ctx *Context, args *GetLocationsArgs, opts ...InvokeOption) (*GetLocationsResult, error)
    func GetLocationsOutput(ctx *Context, args *GetLocationsOutputArgs, opts ...InvokeOption) GetLocationsResultOutput

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

    public static class GetLocations 
    {
        public static Task<GetLocationsResult> InvokeAsync(GetLocationsArgs args, InvokeOptions? opts = null)
        public static Output<GetLocationsResult> Invoke(GetLocationsInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetLocationsResult> getLocations(GetLocationsArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: gcp:artifactregistry/getLocations:getLocations
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Project string
    The project to list versions for. If it is not provided, the provider project is used.
    Project string
    The project to list versions for. If it is not provided, the provider project is used.
    project String
    The project to list versions for. If it is not provided, the provider project is used.
    project string
    The project to list versions for. If it is not provided, the provider project is used.
    project str
    The project to list versions for. If it is not provided, the provider project is used.
    project String
    The project to list versions for. If it is not provided, the provider project is used.

    getLocations Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Locations List<string>
    The list of Artifact Registry locations available for the given project.
    Project string
    Id string
    The provider-assigned unique ID for this managed resource.
    Locations []string
    The list of Artifact Registry locations available for the given project.
    Project string
    id String
    The provider-assigned unique ID for this managed resource.
    locations List<String>
    The list of Artifact Registry locations available for the given project.
    project String
    id string
    The provider-assigned unique ID for this managed resource.
    locations string[]
    The list of Artifact Registry locations available for the given project.
    project string
    id str
    The provider-assigned unique ID for this managed resource.
    locations Sequence[str]
    The list of Artifact Registry locations available for the given project.
    project str
    id String
    The provider-assigned unique ID for this managed resource.
    locations List<String>
    The list of Artifact Registry locations available for the given project.
    project 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 v8.3.1 published on Wednesday, Sep 25, 2024 by Pulumi