1. Packages
  2. Digitalocean Provider
  3. API Docs
  4. getImage
DigitalOcean v4.33.0 published on Thursday, Sep 26, 2024 by Pulumi

digitalocean.getImage

Explore with Pulumi AI

digitalocean logo
DigitalOcean v4.33.0 published on Thursday, Sep 26, 2024 by Pulumi

    Get information on an image for use in other resources (e.g. creating a Droplet based on snapshot). This data source provides all of the image properties as configured on your DigitalOcean account. This is useful if the image in question is not managed by the provider or you need to utilize any of the image’s data.

    An error is triggered if zero or more than one result is returned by the query.

    Example Usage

    Get the data about a snapshot:

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const example1 = digitalocean.getImage({
        name: "example-1.0.0",
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    example1 = digitalocean.get_image(name="example-1.0.0")
    
    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.GetImage(ctx, &digitalocean.GetImageArgs{
    			Name: pulumi.StringRef("example-1.0.0"),
    		}, 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 example1 = DigitalOcean.GetImage.Invoke(new()
        {
            Name = "example-1.0.0",
        });
    
    });
    
    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.GetImageArgs;
    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 example1 = DigitaloceanFunctions.getImage(GetImageArgs.builder()
                .name("example-1.0.0")
                .build());
    
        }
    }
    
    variables:
      example1:
        fn::invoke:
          Function: digitalocean:getImage
          Arguments:
            name: example-1.0.0
    

    Reuse the data about a snapshot to create a Droplet:

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const example = digitalocean.getImage({
        name: "example-1.0.0",
    });
    const exampleDroplet = new digitalocean.Droplet("example", {
        image: example.then(example => example.id),
        name: "example-1",
        region: digitalocean.Region.NYC2,
        size: digitalocean.DropletSlug.DropletS1VCPU1GB,
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    example = digitalocean.get_image(name="example-1.0.0")
    example_droplet = digitalocean.Droplet("example",
        image=example.id,
        name="example-1",
        region=digitalocean.Region.NYC2,
        size=digitalocean.DropletSlug.DROPLET_S1_VCPU1_GB)
    
    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 {
    		example, err := digitalocean.GetImage(ctx, &digitalocean.GetImageArgs{
    			Name: pulumi.StringRef("example-1.0.0"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = digitalocean.NewDroplet(ctx, "example", &digitalocean.DropletArgs{
    			Image:  pulumi.Int(example.Id),
    			Name:   pulumi.String("example-1"),
    			Region: pulumi.String(digitalocean.RegionNYC2),
    			Size:   pulumi.String(digitalocean.DropletSlugDropletS1VCPU1GB),
    		})
    		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 example = DigitalOcean.GetImage.Invoke(new()
        {
            Name = "example-1.0.0",
        });
    
        var exampleDroplet = new DigitalOcean.Droplet("example", new()
        {
            Image = example.Apply(getImageResult => getImageResult.Id),
            Name = "example-1",
            Region = DigitalOcean.Region.NYC2,
            Size = DigitalOcean.DropletSlug.DropletS1VCPU1GB,
        });
    
    });
    
    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.GetImageArgs;
    import com.pulumi.digitalocean.Droplet;
    import com.pulumi.digitalocean.DropletArgs;
    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 example = DigitaloceanFunctions.getImage(GetImageArgs.builder()
                .name("example-1.0.0")
                .build());
    
            var exampleDroplet = new Droplet("exampleDroplet", DropletArgs.builder()
                .image(example.applyValue(getImageResult -> getImageResult.id()))
                .name("example-1")
                .region("nyc2")
                .size("s-1vcpu-1gb")
                .build());
    
        }
    }
    
    resources:
      exampleDroplet:
        type: digitalocean:Droplet
        name: example
        properties:
          image: ${example.id}
          name: example-1
          region: nyc2
          size: s-1vcpu-1gb
    variables:
      example:
        fn::invoke:
          Function: digitalocean:getImage
          Arguments:
            name: example-1.0.0
    

    Get the data about an official image:

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const example2 = digitalocean.getImage({
        slug: "ubuntu-18-04-x64",
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    example2 = digitalocean.get_image(slug="ubuntu-18-04-x64")
    
    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.GetImage(ctx, &digitalocean.GetImageArgs{
    			Slug: pulumi.StringRef("ubuntu-18-04-x64"),
    		}, 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 example2 = DigitalOcean.GetImage.Invoke(new()
        {
            Slug = "ubuntu-18-04-x64",
        });
    
    });
    
    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.GetImageArgs;
    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 example2 = DigitaloceanFunctions.getImage(GetImageArgs.builder()
                .slug("ubuntu-18-04-x64")
                .build());
    
        }
    }
    
    variables:
      example2:
        fn::invoke:
          Function: digitalocean:getImage
          Arguments:
            slug: ubuntu-18-04-x64
    

    Using getImage

    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 getImage(args: GetImageArgs, opts?: InvokeOptions): Promise<GetImageResult>
    function getImageOutput(args: GetImageOutputArgs, opts?: InvokeOptions): Output<GetImageResult>
    def get_image(id: Optional[int] = None,
                  name: Optional[str] = None,
                  slug: Optional[str] = None,
                  source: Optional[str] = None,
                  opts: Optional[InvokeOptions] = None) -> GetImageResult
    def get_image_output(id: Optional[pulumi.Input[int]] = None,
                  name: Optional[pulumi.Input[str]] = None,
                  slug: Optional[pulumi.Input[str]] = None,
                  source: Optional[pulumi.Input[str]] = None,
                  opts: Optional[InvokeOptions] = None) -> Output[GetImageResult]
    func GetImage(ctx *Context, args *GetImageArgs, opts ...InvokeOption) (*GetImageResult, error)
    func GetImageOutput(ctx *Context, args *GetImageOutputArgs, opts ...InvokeOption) GetImageResultOutput

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

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

    The following arguments are supported:

    Id int
    The id of the image
    Name string
    The name of the image.
    Slug string

    The slug of the official image.

    If name is specified, you may also specify:

    Source string
    Restrict the search to one of the following categories of images:
    Id int
    The id of the image
    Name string
    The name of the image.
    Slug string

    The slug of the official image.

    If name is specified, you may also specify:

    Source string
    Restrict the search to one of the following categories of images:
    id Integer
    The id of the image
    name String
    The name of the image.
    slug String

    The slug of the official image.

    If name is specified, you may also specify:

    source String
    Restrict the search to one of the following categories of images:
    id number
    The id of the image
    name string
    The name of the image.
    slug string

    The slug of the official image.

    If name is specified, you may also specify:

    source string
    Restrict the search to one of the following categories of images:
    id int
    The id of the image
    name str
    The name of the image.
    slug str

    The slug of the official image.

    If name is specified, you may also specify:

    source str
    Restrict the search to one of the following categories of images:
    id Number
    The id of the image
    name String
    The name of the image.
    slug String

    The slug of the official image.

    If name is specified, you may also specify:

    source String
    Restrict the search to one of the following categories of images:

    getImage Result

    The following output properties are available:

    Created string
    When the image was created
    Description string
    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.
    Source string
    Created string
    When the image was created
    Description string
    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.
    Source string
    created String
    When the image was created
    description String
    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.
    source String
    created string
    When the image was created
    description string
    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.
    source string
    created str
    When the image was created
    description str
    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.
    source str
    created String
    When the image was created
    description String
    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.
    source String

    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.33.0 published on Thursday, Sep 26, 2024 by Pulumi