1. Packages
  2. Digitalocean Provider
  3. API Docs
  4. getImages
DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi

digitalocean.getImages

Explore with Pulumi AI

digitalocean logo
DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi

    Get information on images for use in other resources (e.g. creating a Droplet based on a snapshot), with the ability to filter and sort the results. If no filters are specified, all images will be returned.

    This data source is useful if the image in question is not managed by the provider or you need to utilize any of the image’s data.

    Note: You can use the digitalocean.getImage data source to obtain metadata about a single image if you already know the slug, unique name, or id to retrieve.

    Example Usage

    Use the filter block with a key string and values list to filter images.

    For example to find all Ubuntu images:

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const ubuntu = digitalocean.getImages({
        filters: [{
            key: "distribution",
            values: ["Ubuntu"],
        }],
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    ubuntu = digitalocean.get_images(filters=[{
        "key": "distribution",
        "values": ["Ubuntu"],
    }])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := digitalocean.GetImages(ctx, &digitalocean.GetImagesArgs{
    			Filters: []digitalocean.GetImagesFilter{
    				{
    					Key: "distribution",
    					Values: []string{
    						"Ubuntu",
    					},
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using DigitalOcean = Pulumi.DigitalOcean;
    
    return await Deployment.RunAsync(() => 
    {
        var ubuntu = DigitalOcean.GetImages.Invoke(new()
        {
            Filters = new[]
            {
                new DigitalOcean.Inputs.GetImagesFilterInputArgs
                {
                    Key = "distribution",
                    Values = new[]
                    {
                        "Ubuntu",
                    },
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.digitalocean.DigitaloceanFunctions;
    import com.pulumi.digitalocean.inputs.GetImagesArgs;
    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 ubuntu = DigitaloceanFunctions.getImages(GetImagesArgs.builder()
                .filters(GetImagesFilterArgs.builder()
                    .key("distribution")
                    .values("Ubuntu")
                    .build())
                .build());
    
        }
    }
    
    variables:
      ubuntu:
        fn::invoke:
          Function: digitalocean:getImages
          Arguments:
            filters:
              - key: distribution
                values:
                  - Ubuntu
    

    You can filter on multiple fields and sort the results as well:

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const available = digitalocean.getImages({
        filters: [
            {
                key: "distribution",
                values: ["Ubuntu"],
            },
            {
                key: "regions",
                values: ["nyc3"],
            },
        ],
        sorts: [{
            key: "created",
            direction: "desc",
        }],
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    available = digitalocean.get_images(filters=[
            {
                "key": "distribution",
                "values": ["Ubuntu"],
            },
            {
                "key": "regions",
                "values": ["nyc3"],
            },
        ],
        sorts=[{
            "key": "created",
            "direction": "desc",
        }])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := digitalocean.GetImages(ctx, &digitalocean.GetImagesArgs{
    			Filters: []digitalocean.GetImagesFilter{
    				{
    					Key: "distribution",
    					Values: []string{
    						"Ubuntu",
    					},
    				},
    				{
    					Key: "regions",
    					Values: []string{
    						"nyc3",
    					},
    				},
    			},
    			Sorts: []digitalocean.GetImagesSort{
    				{
    					Key:       "created",
    					Direction: pulumi.StringRef("desc"),
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using DigitalOcean = Pulumi.DigitalOcean;
    
    return await Deployment.RunAsync(() => 
    {
        var available = DigitalOcean.GetImages.Invoke(new()
        {
            Filters = new[]
            {
                new DigitalOcean.Inputs.GetImagesFilterInputArgs
                {
                    Key = "distribution",
                    Values = new[]
                    {
                        "Ubuntu",
                    },
                },
                new DigitalOcean.Inputs.GetImagesFilterInputArgs
                {
                    Key = "regions",
                    Values = new[]
                    {
                        "nyc3",
                    },
                },
            },
            Sorts = new[]
            {
                new DigitalOcean.Inputs.GetImagesSortInputArgs
                {
                    Key = "created",
                    Direction = "desc",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.digitalocean.DigitaloceanFunctions;
    import com.pulumi.digitalocean.inputs.GetImagesArgs;
    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 = DigitaloceanFunctions.getImages(GetImagesArgs.builder()
                .filters(            
                    GetImagesFilterArgs.builder()
                        .key("distribution")
                        .values("Ubuntu")
                        .build(),
                    GetImagesFilterArgs.builder()
                        .key("regions")
                        .values("nyc3")
                        .build())
                .sorts(GetImagesSortArgs.builder()
                    .key("created")
                    .direction("desc")
                    .build())
                .build());
    
        }
    }
    
    variables:
      available:
        fn::invoke:
          Function: digitalocean:getImages
          Arguments:
            filters:
              - key: distribution
                values:
                  - Ubuntu
              - key: regions
                values:
                  - nyc3
            sorts:
              - key: created
                direction: desc
    

    Using getImages

    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 getImages(args: GetImagesArgs, opts?: InvokeOptions): Promise<GetImagesResult>
    function getImagesOutput(args: GetImagesOutputArgs, opts?: InvokeOptions): Output<GetImagesResult>
    def get_images(filters: Optional[Sequence[GetImagesFilter]] = None,
                   sorts: Optional[Sequence[GetImagesSort]] = None,
                   opts: Optional[InvokeOptions] = None) -> GetImagesResult
    def get_images_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetImagesFilterArgs]]]] = None,
                   sorts: Optional[pulumi.Input[Sequence[pulumi.Input[GetImagesSortArgs]]]] = None,
                   opts: Optional[InvokeOptions] = None) -> Output[GetImagesResult]
    func GetImages(ctx *Context, args *GetImagesArgs, opts ...InvokeOption) (*GetImagesResult, error)
    func GetImagesOutput(ctx *Context, args *GetImagesOutputArgs, opts ...InvokeOption) GetImagesResultOutput

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

    public static class GetImages 
    {
        public static Task<GetImagesResult> InvokeAsync(GetImagesArgs args, InvokeOptions? opts = null)
        public static Output<GetImagesResult> Invoke(GetImagesInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetImagesResult> getImages(GetImagesArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: digitalocean:index/getImages:getImages
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Filters List<Pulumi.DigitalOcean.Inputs.GetImagesFilter>
    Filter the results. The filter block is documented below.
    Sorts List<Pulumi.DigitalOcean.Inputs.GetImagesSort>
    Sort the results. The sort block is documented below.
    Filters []GetImagesFilter
    Filter the results. The filter block is documented below.
    Sorts []GetImagesSort
    Sort the results. The sort block is documented below.
    filters List<GetImagesFilter>
    Filter the results. The filter block is documented below.
    sorts List<GetImagesSort>
    Sort the results. The sort block is documented below.
    filters GetImagesFilter[]
    Filter the results. The filter block is documented below.
    sorts GetImagesSort[]
    Sort the results. The sort block is documented below.
    filters Sequence[GetImagesFilter]
    Filter the results. The filter block is documented below.
    sorts Sequence[GetImagesSort]
    Sort the results. The sort block is documented below.
    filters List<Property Map>
    Filter the results. The filter block is documented below.
    sorts List<Property Map>
    Sort the results. The sort block is documented below.

    getImages Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Images List<Pulumi.DigitalOcean.Outputs.GetImagesImage>
    A set of images satisfying any filter and sort criteria. Each image has the following attributes:
    Filters List<Pulumi.DigitalOcean.Outputs.GetImagesFilter>
    Sorts List<Pulumi.DigitalOcean.Outputs.GetImagesSort>
    Id string
    The provider-assigned unique ID for this managed resource.
    Images []GetImagesImage
    A set of images satisfying any filter and sort criteria. Each image has the following attributes:
    Filters []GetImagesFilter
    Sorts []GetImagesSort
    id String
    The provider-assigned unique ID for this managed resource.
    images List<GetImagesImage>
    A set of images satisfying any filter and sort criteria. Each image has the following attributes:
    filters List<GetImagesFilter>
    sorts List<GetImagesSort>
    id string
    The provider-assigned unique ID for this managed resource.
    images GetImagesImage[]
    A set of images satisfying any filter and sort criteria. Each image has the following attributes:
    filters GetImagesFilter[]
    sorts GetImagesSort[]
    id str
    The provider-assigned unique ID for this managed resource.
    images Sequence[GetImagesImage]
    A set of images satisfying any filter and sort criteria. Each image has the following attributes:
    filters Sequence[GetImagesFilter]
    sorts Sequence[GetImagesSort]
    id String
    The provider-assigned unique ID for this managed resource.
    images List<Property Map>
    A set of images satisfying any filter and sort criteria. Each image has the following attributes:
    filters List<Property Map>
    sorts List<Property Map>

    Supporting Types

    GetImagesFilter

    Key string
    Filter the images by this key. This may be one of distribution, error_message, id, image, min_disk_size, name, private, regions, size_gigabytes, slug, status, tags, or type.
    Values List<string>
    A list of values to match against the key field. Only retrieves images where the key field takes on one or more of the values provided here.
    All bool
    Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.
    MatchBy string
    One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.
    Key string
    Filter the images by this key. This may be one of distribution, error_message, id, image, min_disk_size, name, private, regions, size_gigabytes, slug, status, tags, or type.
    Values []string
    A list of values to match against the key field. Only retrieves images where the key field takes on one or more of the values provided here.
    All bool
    Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.
    MatchBy string
    One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.
    key String
    Filter the images by this key. This may be one of distribution, error_message, id, image, min_disk_size, name, private, regions, size_gigabytes, slug, status, tags, or type.
    values List<String>
    A list of values to match against the key field. Only retrieves images where the key field takes on one or more of the values provided here.
    all Boolean
    Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.
    matchBy String
    One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.
    key string
    Filter the images by this key. This may be one of distribution, error_message, id, image, min_disk_size, name, private, regions, size_gigabytes, slug, status, tags, or type.
    values string[]
    A list of values to match against the key field. Only retrieves images where the key field takes on one or more of the values provided here.
    all boolean
    Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.
    matchBy string
    One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.
    key str
    Filter the images by this key. This may be one of distribution, error_message, id, image, min_disk_size, name, private, regions, size_gigabytes, slug, status, tags, or type.
    values Sequence[str]
    A list of values to match against the key field. Only retrieves images where the key field takes on one or more of the values provided here.
    all bool
    Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.
    match_by str
    One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.
    key String
    Filter the images by this key. This may be one of distribution, error_message, id, image, min_disk_size, name, private, regions, size_gigabytes, slug, status, tags, or type.
    values List<String>
    A list of values to match against the key field. Only retrieves images where the key field takes on one or more of the values provided here.
    all Boolean
    Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.
    matchBy String
    One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.

    GetImagesImage

    Created string
    When the image was created
    Description string
    a description of the image
    Distribution string
    The name of the distribution of the OS of the image.
    ErrorMessage string
    Any applicable error message pertaining to the image
    Id int
    The ID of the image.
    Image string
    The id of the image (legacy parameter).
    MinDiskSize int
    The minimum 'disk' required for the image.
    Name string
    The name of the image.
    Private bool
    Is image a public image or not. Public images represent Linux distributions or One-Click Applications, while non-public images represent snapshots and backups and are only available within your account.
    Regions List<string>
    A set of the regions that the image is available in.
    SizeGigabytes double
    The size of the image in GB.
    Slug string
    Unique text identifier of the image.
    Status string
    Current status of the image
    Tags List<string>
    A set of tags applied to the image
    Type string
    Type of the image.
    Created string
    When the image was created
    Description string
    a description of the image
    Distribution string
    The name of the distribution of the OS of the image.
    ErrorMessage string
    Any applicable error message pertaining to the image
    Id int
    The ID of the image.
    Image string
    The id of the image (legacy parameter).
    MinDiskSize int
    The minimum 'disk' required for the image.
    Name string
    The name of the image.
    Private bool
    Is image a public image or not. Public images represent Linux distributions or One-Click Applications, while non-public images represent snapshots and backups and are only available within your account.
    Regions []string
    A set of the regions that the image is available in.
    SizeGigabytes float64
    The size of the image in GB.
    Slug string
    Unique text identifier of the image.
    Status string
    Current status of the image
    Tags []string
    A set of tags applied to the image
    Type string
    Type of the image.
    created String
    When the image was created
    description String
    a description of the image
    distribution String
    The name of the distribution of the OS of the image.
    errorMessage String
    Any applicable error message pertaining to the image
    id Integer
    The ID of the image.
    image String
    The id of the image (legacy parameter).
    minDiskSize Integer
    The minimum 'disk' required for the image.
    name String
    The name of the image.
    private_ Boolean
    Is image a public image or not. Public images represent Linux distributions or One-Click Applications, while non-public images represent snapshots and backups and are only available within your account.
    regions List<String>
    A set of the regions that the image is available in.
    sizeGigabytes Double
    The size of the image in GB.
    slug String
    Unique text identifier of the image.
    status String
    Current status of the image
    tags List<String>
    A set of tags applied to the image
    type String
    Type of the image.
    created string
    When the image was created
    description string
    a description of the image
    distribution string
    The name of the distribution of the OS of the image.
    errorMessage string
    Any applicable error message pertaining to the image
    id number
    The ID of the image.
    image string
    The id of the image (legacy parameter).
    minDiskSize number
    The minimum 'disk' required for the image.
    name string
    The name of the image.
    private boolean
    Is image a public image or not. Public images represent Linux distributions or One-Click Applications, while non-public images represent snapshots and backups and are only available within your account.
    regions string[]
    A set of the regions that the image is available in.
    sizeGigabytes number
    The size of the image in GB.
    slug string
    Unique text identifier of the image.
    status string
    Current status of the image
    tags string[]
    A set of tags applied to the image
    type string
    Type of the image.
    created str
    When the image was created
    description str
    a description of the image
    distribution str
    The name of the distribution of the OS of the image.
    error_message str
    Any applicable error message pertaining to the image
    id int
    The ID of the image.
    image str
    The id of the image (legacy parameter).
    min_disk_size int
    The minimum 'disk' required for the image.
    name str
    The name of the image.
    private bool
    Is image a public image or not. Public images represent Linux distributions or One-Click Applications, while non-public images represent snapshots and backups and are only available within your account.
    regions Sequence[str]
    A set of the regions that the image is available in.
    size_gigabytes float
    The size of the image in GB.
    slug str
    Unique text identifier of the image.
    status str
    Current status of the image
    tags Sequence[str]
    A set of tags applied to the image
    type str
    Type of the image.
    created String
    When the image was created
    description String
    a description of the image
    distribution String
    The name of the distribution of the OS of the image.
    errorMessage String
    Any applicable error message pertaining to the image
    id Number
    The ID of the image.
    image String
    The id of the image (legacy parameter).
    minDiskSize Number
    The minimum 'disk' required for the image.
    name String
    The name of the image.
    private Boolean
    Is image a public image or not. Public images represent Linux distributions or One-Click Applications, while non-public images represent snapshots and backups and are only available within your account.
    regions List<String>
    A set of the regions that the image is available in.
    sizeGigabytes Number
    The size of the image in GB.
    slug String
    Unique text identifier of the image.
    status String
    Current status of the image
    tags List<String>
    A set of tags applied to the image
    type String
    Type of the image.

    GetImagesSort

    Key string
    Sort the images by this key. This may be one of distribution, error_message, id, image, min_disk_size, name, private, size_gigabytes, slug, status, or type.
    Direction string
    The sort direction. This may be either asc or desc.
    Key string
    Sort the images by this key. This may be one of distribution, error_message, id, image, min_disk_size, name, private, size_gigabytes, slug, status, or type.
    Direction string
    The sort direction. This may be either asc or desc.
    key String
    Sort the images by this key. This may be one of distribution, error_message, id, image, min_disk_size, name, private, size_gigabytes, slug, status, or type.
    direction String
    The sort direction. This may be either asc or desc.
    key string
    Sort the images by this key. This may be one of distribution, error_message, id, image, min_disk_size, name, private, size_gigabytes, slug, status, or type.
    direction string
    The sort direction. This may be either asc or desc.
    key str
    Sort the images by this key. This may be one of distribution, error_message, id, image, min_disk_size, name, private, size_gigabytes, slug, status, or type.
    direction str
    The sort direction. This may be either asc or desc.
    key String
    Sort the images by this key. This may be one of distribution, error_message, id, image, min_disk_size, name, private, size_gigabytes, slug, status, or type.
    direction String
    The sort direction. This may be either asc or desc.

    Package Details

    Repository
    DigitalOcean pulumi/pulumi-digitalocean
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the digitalocean Terraform Provider.
    digitalocean logo
    DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi