1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. artifactregistry
  5. getDockerImage
Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi

gcp.artifactregistry.getDockerImage

Explore with Pulumi AI

gcp logo
Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi

    This data source fetches information from a provided Artifact Registry repository, including the fully qualified name and URI for an image, based on a the latest version of image name and optional digest or tag.

    Note Requires one of the following OAuth scopes: https://www.googleapis.com/auth/cloud-platform or https://www.googleapis.com/auth/cloud-platform.read-only.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const myRepo = new gcp.artifactregistry.Repository("my_repo", {
        location: "us-west1",
        repositoryId: "my-repository",
        format: "DOCKER",
    });
    const myImage = gcp.artifactregistry.getDockerImageOutput({
        location: myRepo.location,
        repositoryId: myRepo.repositoryId,
        imageName: "my-image:my-tag",
    });
    const _default = new gcp.cloudrunv2.Service("default", {template: {
        containers: [{
            image: myImage.apply(myImage => myImage.selfLink),
        }],
    }});
    
    import pulumi
    import pulumi_gcp as gcp
    
    my_repo = gcp.artifactregistry.Repository("my_repo",
        location="us-west1",
        repository_id="my-repository",
        format="DOCKER")
    my_image = gcp.artifactregistry.get_docker_image_output(location=my_repo.location,
        repository_id=my_repo.repository_id,
        image_name="my-image:my-tag")
    default = gcp.cloudrunv2.Service("default", template={
        "containers": [{
            "image": my_image.self_link,
        }],
    })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/artifactregistry"
    	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/cloudrunv2"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		myRepo, err := artifactregistry.NewRepository(ctx, "my_repo", &artifactregistry.RepositoryArgs{
    			Location:     pulumi.String("us-west1"),
    			RepositoryId: pulumi.String("my-repository"),
    			Format:       pulumi.String("DOCKER"),
    		})
    		if err != nil {
    			return err
    		}
    		myImage := artifactregistry.GetDockerImageOutput(ctx, artifactregistry.GetDockerImageOutputArgs{
    			Location:     myRepo.Location,
    			RepositoryId: myRepo.RepositoryId,
    			ImageName:    pulumi.String("my-image:my-tag"),
    		}, nil)
    		_, err = cloudrunv2.NewService(ctx, "default", &cloudrunv2.ServiceArgs{
    			Template: &cloudrunv2.ServiceTemplateArgs{
    				Containers: cloudrunv2.ServiceTemplateContainerArray{
    					&cloudrunv2.ServiceTemplateContainerArgs{
    						Image: myImage.ApplyT(func(myImage artifactregistry.GetDockerImageResult) (*string, error) {
    							return &myImage.SelfLink, nil
    						}).(pulumi.StringPtrOutput),
    					},
    				},
    			},
    		})
    		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 myRepo = new Gcp.ArtifactRegistry.Repository("my_repo", new()
        {
            Location = "us-west1",
            RepositoryId = "my-repository",
            Format = "DOCKER",
        });
    
        var myImage = Gcp.ArtifactRegistry.GetDockerImage.Invoke(new()
        {
            Location = myRepo.Location,
            RepositoryId = myRepo.RepositoryId,
            ImageName = "my-image:my-tag",
        });
    
        var @default = new Gcp.CloudRunV2.Service("default", new()
        {
            Template = new Gcp.CloudRunV2.Inputs.ServiceTemplateArgs
            {
                Containers = new[]
                {
                    new Gcp.CloudRunV2.Inputs.ServiceTemplateContainerArgs
                    {
                        Image = myImage.Apply(getDockerImageResult => getDockerImageResult.SelfLink),
                    },
                },
            },
        });
    
    });
    
    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.GetDockerImageArgs;
    import com.pulumi.gcp.cloudrunv2.Service;
    import com.pulumi.gcp.cloudrunv2.ServiceArgs;
    import com.pulumi.gcp.cloudrunv2.inputs.ServiceTemplateArgs;
    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 myRepo = new Repository("myRepo", RepositoryArgs.builder()
                .location("us-west1")
                .repositoryId("my-repository")
                .format("DOCKER")
                .build());
    
            final var myImage = ArtifactregistryFunctions.getDockerImage(GetDockerImageArgs.builder()
                .location(myRepo.location())
                .repositoryId(myRepo.repositoryId())
                .imageName("my-image:my-tag")
                .build());
    
            var default_ = new Service("default", ServiceArgs.builder()
                .template(ServiceTemplateArgs.builder()
                    .containers(ServiceTemplateContainerArgs.builder()
                        .image(myImage.applyValue(getDockerImageResult -> getDockerImageResult).applyValue(myImage -> myImage.applyValue(getDockerImageResult -> getDockerImageResult.selfLink())))
                        .build())
                    .build())
                .build());
    
        }
    }
    
    resources:
      myRepo:
        type: gcp:artifactregistry:Repository
        name: my_repo
        properties:
          location: us-west1
          repositoryId: my-repository
          format: DOCKER
      default:
        type: gcp:cloudrunv2:Service
        properties:
          template:
            containers:
              - image: ${myImage.selfLink}
    variables:
      myImage:
        fn::invoke:
          Function: gcp:artifactregistry:getDockerImage
          Arguments:
            location: ${myRepo.location}
            repositoryId: ${myRepo.repositoryId}
            imageName: my-image:my-tag
    

    Using getDockerImage

    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 getDockerImage(args: GetDockerImageArgs, opts?: InvokeOptions): Promise<GetDockerImageResult>
    function getDockerImageOutput(args: GetDockerImageOutputArgs, opts?: InvokeOptions): Output<GetDockerImageResult>
    def get_docker_image(image_name: Optional[str] = None,
                         location: Optional[str] = None,
                         project: Optional[str] = None,
                         repository_id: Optional[str] = None,
                         opts: Optional[InvokeOptions] = None) -> GetDockerImageResult
    def get_docker_image_output(image_name: Optional[pulumi.Input[str]] = None,
                         location: Optional[pulumi.Input[str]] = None,
                         project: Optional[pulumi.Input[str]] = None,
                         repository_id: Optional[pulumi.Input[str]] = None,
                         opts: Optional[InvokeOptions] = None) -> Output[GetDockerImageResult]
    func GetDockerImage(ctx *Context, args *GetDockerImageArgs, opts ...InvokeOption) (*GetDockerImageResult, error)
    func GetDockerImageOutput(ctx *Context, args *GetDockerImageOutputArgs, opts ...InvokeOption) GetDockerImageResultOutput

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

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

    The following arguments are supported:

    ImageName string
    The image name to fetch. If no digest or tag is provided, then the latest modified image will be used.
    Location string
    The location of the artifact registry.
    RepositoryId string
    The last part of the repository name to fetch from.
    Project string
    The project ID in which the resource belongs. If it is not provided, the provider project is used.
    ImageName string
    The image name to fetch. If no digest or tag is provided, then the latest modified image will be used.
    Location string
    The location of the artifact registry.
    RepositoryId string
    The last part of the repository name to fetch from.
    Project string
    The project ID in which the resource belongs. If it is not provided, the provider project is used.
    imageName String
    The image name to fetch. If no digest or tag is provided, then the latest modified image will be used.
    location String
    The location of the artifact registry.
    repositoryId String
    The last part of the repository name to fetch from.
    project String
    The project ID in which the resource belongs. If it is not provided, the provider project is used.
    imageName string
    The image name to fetch. If no digest or tag is provided, then the latest modified image will be used.
    location string
    The location of the artifact registry.
    repositoryId string
    The last part of the repository name to fetch from.
    project string
    The project ID in which the resource belongs. If it is not provided, the provider project is used.
    image_name str
    The image name to fetch. If no digest or tag is provided, then the latest modified image will be used.
    location str
    The location of the artifact registry.
    repository_id str
    The last part of the repository name to fetch from.
    project str
    The project ID in which the resource belongs. If it is not provided, the provider project is used.
    imageName String
    The image name to fetch. If no digest or tag is provided, then the latest modified image will be used.
    location String
    The location of the artifact registry.
    repositoryId String
    The last part of the repository name to fetch from.
    project String
    The project ID in which the resource belongs. If it is not provided, the provider project is used.

    getDockerImage Result

    The following output properties are available:

    BuildTime string
    The time, as a RFC 3339 string, this image was built.
    Id string
    The provider-assigned unique ID for this managed resource.
    ImageName string
    ImageSizeBytes string
    Calculated size of the image in bytes.
    Location string
    MediaType string
    Media type of this image, e.g. application/vnd.docker.distribution.manifest.v2+json.
    Name string
    The fully qualified name of the fetched image. This name has the form: projects/{{project}}/locations/{{location}}/repository/{{repository_id}}/dockerImages/{{docker_image}}. For example,

    projects/test-project/locations/us-west4/repositories/test-repo/dockerImages/nginx@sha256:e9954c1fc875017be1c3e36eca16be2d9e9bccc4bf072163515467d6a823c7cf
    
    RepositoryId string
    SelfLink string
    The URI to access the image. For example,

    us-west4-docker.pkg.dev/test-project/test-repo/nginx@sha256:e9954c1fc875017be1c3e36eca16be2d9e9bccc4bf072163515467d6a823c7cf
    
    Tags List<string>
    A list of all tags associated with the image.
    UpdateTime string
    The time, as a RFC 3339 string, this image was updated.
    UploadTime string
    The time, as a RFC 3339 string, the image was uploaded. For example, 2014-10-02T15:01:23.045123456Z.
    Project string
    BuildTime string
    The time, as a RFC 3339 string, this image was built.
    Id string
    The provider-assigned unique ID for this managed resource.
    ImageName string
    ImageSizeBytes string
    Calculated size of the image in bytes.
    Location string
    MediaType string
    Media type of this image, e.g. application/vnd.docker.distribution.manifest.v2+json.
    Name string
    The fully qualified name of the fetched image. This name has the form: projects/{{project}}/locations/{{location}}/repository/{{repository_id}}/dockerImages/{{docker_image}}. For example,

    projects/test-project/locations/us-west4/repositories/test-repo/dockerImages/nginx@sha256:e9954c1fc875017be1c3e36eca16be2d9e9bccc4bf072163515467d6a823c7cf
    
    RepositoryId string
    SelfLink string
    The URI to access the image. For example,

    us-west4-docker.pkg.dev/test-project/test-repo/nginx@sha256:e9954c1fc875017be1c3e36eca16be2d9e9bccc4bf072163515467d6a823c7cf
    
    Tags []string
    A list of all tags associated with the image.
    UpdateTime string
    The time, as a RFC 3339 string, this image was updated.
    UploadTime string
    The time, as a RFC 3339 string, the image was uploaded. For example, 2014-10-02T15:01:23.045123456Z.
    Project string
    buildTime String
    The time, as a RFC 3339 string, this image was built.
    id String
    The provider-assigned unique ID for this managed resource.
    imageName String
    imageSizeBytes String
    Calculated size of the image in bytes.
    location String
    mediaType String
    Media type of this image, e.g. application/vnd.docker.distribution.manifest.v2+json.
    name String
    The fully qualified name of the fetched image. This name has the form: projects/{{project}}/locations/{{location}}/repository/{{repository_id}}/dockerImages/{{docker_image}}. For example,

    projects/test-project/locations/us-west4/repositories/test-repo/dockerImages/nginx@sha256:e9954c1fc875017be1c3e36eca16be2d9e9bccc4bf072163515467d6a823c7cf
    
    repositoryId String
    selfLink String
    The URI to access the image. For example,

    us-west4-docker.pkg.dev/test-project/test-repo/nginx@sha256:e9954c1fc875017be1c3e36eca16be2d9e9bccc4bf072163515467d6a823c7cf
    
    tags List<String>
    A list of all tags associated with the image.
    updateTime String
    The time, as a RFC 3339 string, this image was updated.
    uploadTime String
    The time, as a RFC 3339 string, the image was uploaded. For example, 2014-10-02T15:01:23.045123456Z.
    project String
    buildTime string
    The time, as a RFC 3339 string, this image was built.
    id string
    The provider-assigned unique ID for this managed resource.
    imageName string
    imageSizeBytes string
    Calculated size of the image in bytes.
    location string
    mediaType string
    Media type of this image, e.g. application/vnd.docker.distribution.manifest.v2+json.
    name string
    The fully qualified name of the fetched image. This name has the form: projects/{{project}}/locations/{{location}}/repository/{{repository_id}}/dockerImages/{{docker_image}}. For example,

    projects/test-project/locations/us-west4/repositories/test-repo/dockerImages/nginx@sha256:e9954c1fc875017be1c3e36eca16be2d9e9bccc4bf072163515467d6a823c7cf
    
    repositoryId string
    selfLink string
    The URI to access the image. For example,

    us-west4-docker.pkg.dev/test-project/test-repo/nginx@sha256:e9954c1fc875017be1c3e36eca16be2d9e9bccc4bf072163515467d6a823c7cf
    
    tags string[]
    A list of all tags associated with the image.
    updateTime string
    The time, as a RFC 3339 string, this image was updated.
    uploadTime string
    The time, as a RFC 3339 string, the image was uploaded. For example, 2014-10-02T15:01:23.045123456Z.
    project string
    build_time str
    The time, as a RFC 3339 string, this image was built.
    id str
    The provider-assigned unique ID for this managed resource.
    image_name str
    image_size_bytes str
    Calculated size of the image in bytes.
    location str
    media_type str
    Media type of this image, e.g. application/vnd.docker.distribution.manifest.v2+json.
    name str
    The fully qualified name of the fetched image. This name has the form: projects/{{project}}/locations/{{location}}/repository/{{repository_id}}/dockerImages/{{docker_image}}. For example,

    projects/test-project/locations/us-west4/repositories/test-repo/dockerImages/nginx@sha256:e9954c1fc875017be1c3e36eca16be2d9e9bccc4bf072163515467d6a823c7cf
    
    repository_id str
    self_link str
    The URI to access the image. For example,

    us-west4-docker.pkg.dev/test-project/test-repo/nginx@sha256:e9954c1fc875017be1c3e36eca16be2d9e9bccc4bf072163515467d6a823c7cf
    
    tags Sequence[str]
    A list of all tags associated with the image.
    update_time str
    The time, as a RFC 3339 string, this image was updated.
    upload_time str
    The time, as a RFC 3339 string, the image was uploaded. For example, 2014-10-02T15:01:23.045123456Z.
    project str
    buildTime String
    The time, as a RFC 3339 string, this image was built.
    id String
    The provider-assigned unique ID for this managed resource.
    imageName String
    imageSizeBytes String
    Calculated size of the image in bytes.
    location String
    mediaType String
    Media type of this image, e.g. application/vnd.docker.distribution.manifest.v2+json.
    name String
    The fully qualified name of the fetched image. This name has the form: projects/{{project}}/locations/{{location}}/repository/{{repository_id}}/dockerImages/{{docker_image}}. For example,

    projects/test-project/locations/us-west4/repositories/test-repo/dockerImages/nginx@sha256:e9954c1fc875017be1c3e36eca16be2d9e9bccc4bf072163515467d6a823c7cf
    
    repositoryId String
    selfLink String
    The URI to access the image. For example,

    us-west4-docker.pkg.dev/test-project/test-repo/nginx@sha256:e9954c1fc875017be1c3e36eca16be2d9e9bccc4bf072163515467d6a823c7cf
    
    tags List<String>
    A list of all tags associated with the image.
    updateTime String
    The time, as a RFC 3339 string, this image was updated.
    uploadTime String
    The time, as a RFC 3339 string, the image was uploaded. For example, 2014-10-02T15:01:23.045123456Z.
    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.9.3 published on Monday, Nov 18, 2024 by Pulumi