1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. artifactregistry
  5. getNpmPackage
Google Cloud v9.0.0 published on Thursday, Sep 18, 2025 by Pulumi

gcp.artifactregistry.getNpmPackage

Explore with Pulumi AI

gcp logo
Google Cloud v9.0.0 published on Thursday, Sep 18, 2025 by Pulumi

    This data source fetches information from a provided Artifact Registry repository, based on a the latest version of the package and optional version.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const npmRepo = new gcp.artifactregistry.Repository("npm_repo", {
        location: "us-central1",
        repositoryId: "my-npm-repo",
        format: "NPM",
    });
    const latest = gcp.artifactregistry.getNpmPackageOutput({
        location: npmRepo.location,
        repositoryId: npmRepo.repositoryId,
        packageName: "example-pkg",
    });
    const withVersion = gcp.artifactregistry.getNpmPackageOutput({
        location: npmRepo.location,
        repositoryId: npmRepo.repositoryId,
        packageName: "example-pkg:1.0.0",
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    npm_repo = gcp.artifactregistry.Repository("npm_repo",
        location="us-central1",
        repository_id="my-npm-repo",
        format="NPM")
    latest = gcp.artifactregistry.get_npm_package_output(location=npm_repo.location,
        repository_id=npm_repo.repository_id,
        package_name="example-pkg")
    with_version = gcp.artifactregistry.get_npm_package_output(location=npm_repo.location,
        repository_id=npm_repo.repository_id,
        package_name="example-pkg:1.0.0")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/artifactregistry"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		npmRepo, err := artifactregistry.NewRepository(ctx, "npm_repo", &artifactregistry.RepositoryArgs{
    			Location:     pulumi.String("us-central1"),
    			RepositoryId: pulumi.String("my-npm-repo"),
    			Format:       pulumi.String("NPM"),
    		})
    		if err != nil {
    			return err
    		}
    		_ = artifactregistry.GetNpmPackageOutput(ctx, artifactregistry.GetNpmPackageOutputArgs{
    			Location:     npmRepo.Location,
    			RepositoryId: npmRepo.RepositoryId,
    			PackageName:  pulumi.String("example-pkg"),
    		}, nil)
    		_ = artifactregistry.GetNpmPackageOutput(ctx, artifactregistry.GetNpmPackageOutputArgs{
    			Location:     npmRepo.Location,
    			RepositoryId: npmRepo.RepositoryId,
    			PackageName:  pulumi.String("example-pkg:1.0.0"),
    		}, nil)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var npmRepo = new Gcp.ArtifactRegistry.Repository("npm_repo", new()
        {
            Location = "us-central1",
            RepositoryId = "my-npm-repo",
            Format = "NPM",
        });
    
        var latest = Gcp.ArtifactRegistry.GetNpmPackage.Invoke(new()
        {
            Location = npmRepo.Location,
            RepositoryId = npmRepo.RepositoryId,
            PackageName = "example-pkg",
        });
    
        var withVersion = Gcp.ArtifactRegistry.GetNpmPackage.Invoke(new()
        {
            Location = npmRepo.Location,
            RepositoryId = npmRepo.RepositoryId,
            PackageName = "example-pkg:1.0.0",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.artifactregistry.Repository;
    import com.pulumi.gcp.artifactregistry.RepositoryArgs;
    import com.pulumi.gcp.artifactregistry.ArtifactregistryFunctions;
    import com.pulumi.gcp.artifactregistry.inputs.GetNpmPackageArgs;
    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) {
            var npmRepo = new Repository("npmRepo", RepositoryArgs.builder()
                .location("us-central1")
                .repositoryId("my-npm-repo")
                .format("NPM")
                .build());
    
            final var latest = ArtifactregistryFunctions.getNpmPackage(GetNpmPackageArgs.builder()
                .location(npmRepo.location())
                .repositoryId(npmRepo.repositoryId())
                .packageName("example-pkg")
                .build());
    
            final var withVersion = ArtifactregistryFunctions.getNpmPackage(GetNpmPackageArgs.builder()
                .location(npmRepo.location())
                .repositoryId(npmRepo.repositoryId())
                .packageName("example-pkg:1.0.0")
                .build());
    
        }
    }
    
    resources:
      npmRepo:
        type: gcp:artifactregistry:Repository
        name: npm_repo
        properties:
          location: us-central1
          repositoryId: my-npm-repo
          format: NPM
    variables:
      latest:
        fn::invoke:
          function: gcp:artifactregistry:getNpmPackage
          arguments:
            location: ${npmRepo.location}
            repositoryId: ${npmRepo.repositoryId}
            packageName: example-pkg
      withVersion:
        fn::invoke:
          function: gcp:artifactregistry:getNpmPackage
          arguments:
            location: ${npmRepo.location}
            repositoryId: ${npmRepo.repositoryId}
            packageName: example-pkg:1.0.0
    

    Using getNpmPackage

    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 getNpmPackage(args: GetNpmPackageArgs, opts?: InvokeOptions): Promise<GetNpmPackageResult>
    function getNpmPackageOutput(args: GetNpmPackageOutputArgs, opts?: InvokeOptions): Output<GetNpmPackageResult>
    def get_npm_package(location: Optional[str] = None,
                        package_name: Optional[str] = None,
                        project: Optional[str] = None,
                        repository_id: Optional[str] = None,
                        opts: Optional[InvokeOptions] = None) -> GetNpmPackageResult
    def get_npm_package_output(location: Optional[pulumi.Input[str]] = None,
                        package_name: Optional[pulumi.Input[str]] = None,
                        project: Optional[pulumi.Input[str]] = None,
                        repository_id: Optional[pulumi.Input[str]] = None,
                        opts: Optional[InvokeOptions] = None) -> Output[GetNpmPackageResult]
    func GetNpmPackage(ctx *Context, args *GetNpmPackageArgs, opts ...InvokeOption) (*GetNpmPackageResult, error)
    func GetNpmPackageOutput(ctx *Context, args *GetNpmPackageOutputArgs, opts ...InvokeOption) GetNpmPackageResultOutput

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

    public static class GetNpmPackage 
    {
        public static Task<GetNpmPackageResult> InvokeAsync(GetNpmPackageArgs args, InvokeOptions? opts = null)
        public static Output<GetNpmPackageResult> Invoke(GetNpmPackageInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetNpmPackageResult> getNpmPackage(GetNpmPackageArgs args, InvokeOptions options)
    public static Output<GetNpmPackageResult> getNpmPackage(GetNpmPackageArgs args, InvokeOptions options)
    
    fn::invoke:
      function: gcp:artifactregistry/getNpmPackage:getNpmPackage
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Location string
    The location of the Artifact Registry repository.
    PackageName string
    The name of the package to fetch. Can optionally include a specific version (e.g., my_pkg:1.2.3). If no version is provided, the latest version is used.
    RepositoryId string
    The ID of the repository containing the NPM package.
    Project string
    The ID of the project that owns the repository. If not provided, the provider-level project is used.
    Location string
    The location of the Artifact Registry repository.
    PackageName string
    The name of the package to fetch. Can optionally include a specific version (e.g., my_pkg:1.2.3). If no version is provided, the latest version is used.
    RepositoryId string
    The ID of the repository containing the NPM package.
    Project string
    The ID of the project that owns the repository. If not provided, the provider-level project is used.
    location String
    The location of the Artifact Registry repository.
    packageName String
    The name of the package to fetch. Can optionally include a specific version (e.g., my_pkg:1.2.3). If no version is provided, the latest version is used.
    repositoryId String
    The ID of the repository containing the NPM package.
    project String
    The ID of the project that owns the repository. If not provided, the provider-level project is used.
    location string
    The location of the Artifact Registry repository.
    packageName string
    The name of the package to fetch. Can optionally include a specific version (e.g., my_pkg:1.2.3). If no version is provided, the latest version is used.
    repositoryId string
    The ID of the repository containing the NPM package.
    project string
    The ID of the project that owns the repository. If not provided, the provider-level project is used.
    location str
    The location of the Artifact Registry repository.
    package_name str
    The name of the package to fetch. Can optionally include a specific version (e.g., my_pkg:1.2.3). If no version is provided, the latest version is used.
    repository_id str
    The ID of the repository containing the NPM package.
    project str
    The ID of the project that owns the repository. If not provided, the provider-level project is used.
    location String
    The location of the Artifact Registry repository.
    packageName String
    The name of the package to fetch. Can optionally include a specific version (e.g., my_pkg:1.2.3). If no version is provided, the latest version is used.
    repositoryId String
    The ID of the repository containing the NPM package.
    project String
    The ID of the project that owns the repository. If not provided, the provider-level project is used.

    getNpmPackage Result

    The following output properties are available:

    CreateTime string
    The time the package was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    Location string
    Name string
    The fully qualified name of the fetched package. Format:

    projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/npmPackages/{{package}}:{{version}}
    
    PackageName string
    RepositoryId string
    Tags List<string>
    A list of all Tags attached to this package.
    UpdateTime string
    The time the package was last updated.
    Version string
    The version of the NPM package.
    Project string
    CreateTime string
    The time the package was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    Location string
    Name string
    The fully qualified name of the fetched package. Format:

    projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/npmPackages/{{package}}:{{version}}
    
    PackageName string
    RepositoryId string
    Tags []string
    A list of all Tags attached to this package.
    UpdateTime string
    The time the package was last updated.
    Version string
    The version of the NPM package.
    Project string
    createTime String
    The time the package was created.
    id String
    The provider-assigned unique ID for this managed resource.
    location String
    name String
    The fully qualified name of the fetched package. Format:

    projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/npmPackages/{{package}}:{{version}}
    
    packageName String
    repositoryId String
    tags List<String>
    A list of all Tags attached to this package.
    updateTime String
    The time the package was last updated.
    version String
    The version of the NPM package.
    project String
    createTime string
    The time the package was created.
    id string
    The provider-assigned unique ID for this managed resource.
    location string
    name string
    The fully qualified name of the fetched package. Format:

    projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/npmPackages/{{package}}:{{version}}
    
    packageName string
    repositoryId string
    tags string[]
    A list of all Tags attached to this package.
    updateTime string
    The time the package was last updated.
    version string
    The version of the NPM package.
    project string
    create_time str
    The time the package was created.
    id str
    The provider-assigned unique ID for this managed resource.
    location str
    name str
    The fully qualified name of the fetched package. Format:

    projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/npmPackages/{{package}}:{{version}}
    
    package_name str
    repository_id str
    tags Sequence[str]
    A list of all Tags attached to this package.
    update_time str
    The time the package was last updated.
    version str
    The version of the NPM package.
    project str
    createTime String
    The time the package was created.
    id String
    The provider-assigned unique ID for this managed resource.
    location String
    name String
    The fully qualified name of the fetched package. Format:

    projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/npmPackages/{{package}}:{{version}}
    
    packageName String
    repositoryId String
    tags List<String>
    A list of all Tags attached to this package.
    updateTime String
    The time the package was last updated.
    version String
    The version of the NPM package.
    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 v9.0.0 published on Thursday, Sep 18, 2025 by Pulumi