1. Packages
  2. Ucloud Provider
  3. API Docs
  4. getImages
ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud

ucloud.getImages

Explore with Pulumi AI

ucloud logo
ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud

    This data source providers a list of available image resources according to their availability zone, image ID and other fields.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as ucloud from "@pulumi/ucloud";
    
    const example = ucloud.getImages({
        availabilityZone: "cn-bj2-02",
        imageType: "base",
        nameRegex: "^CentOS 7.[1-2] 64",
        mostRecent: true,
    });
    export const first = example.then(example => example.images?.[0]?.id);
    
    import pulumi
    import pulumi_ucloud as ucloud
    
    example = ucloud.get_images(availability_zone="cn-bj2-02",
        image_type="base",
        name_regex="^CentOS 7.[1-2] 64",
        most_recent=True)
    pulumi.export("first", example.images[0].id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ucloud/ucloud"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := ucloud.GetImages(ctx, &ucloud.GetImagesArgs{
    			AvailabilityZone: pulumi.StringRef("cn-bj2-02"),
    			ImageType:        pulumi.StringRef("base"),
    			NameRegex:        pulumi.StringRef("^CentOS 7.[1-2] 64"),
    			MostRecent:       pulumi.BoolRef(true),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("first", example.Images[0].Id)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ucloud = Pulumi.Ucloud;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Ucloud.GetImages.Invoke(new()
        {
            AvailabilityZone = "cn-bj2-02",
            ImageType = "base",
            NameRegex = "^CentOS 7.[1-2] 64",
            MostRecent = true,
        });
    
        return new Dictionary<string, object?>
        {
            ["first"] = example.Apply(getImagesResult => getImagesResult.Images[0]?.Id),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ucloud.UcloudFunctions;
    import com.pulumi.ucloud.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 example = UcloudFunctions.getImages(GetImagesArgs.builder()
                .availabilityZone("cn-bj2-02")
                .imageType("base")
                .nameRegex("^CentOS 7.[1-2] 64")
                .mostRecent(true)
                .build());
    
            ctx.export("first", example.applyValue(getImagesResult -> getImagesResult.images()[0].id()));
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: ucloud:getImages
          arguments:
            availabilityZone: cn-bj2-02
            imageType: base
            nameRegex: ^CentOS 7.[1-2] 64
            mostRecent: true
    outputs:
      first: ${example.images[0].id}
    

    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(availability_zone: Optional[str] = None,
                   id: Optional[str] = None,
                   ids: Optional[Sequence[str]] = None,
                   image_id: Optional[str] = None,
                   image_type: Optional[str] = None,
                   most_recent: Optional[bool] = None,
                   name_regex: Optional[str] = None,
                   os_type: Optional[str] = None,
                   output_file: Optional[str] = None,
                   opts: Optional[InvokeOptions] = None) -> GetImagesResult
    def get_images_output(availability_zone: Optional[pulumi.Input[str]] = None,
                   id: Optional[pulumi.Input[str]] = None,
                   ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                   image_id: Optional[pulumi.Input[str]] = None,
                   image_type: Optional[pulumi.Input[str]] = None,
                   most_recent: Optional[pulumi.Input[bool]] = None,
                   name_regex: Optional[pulumi.Input[str]] = None,
                   os_type: Optional[pulumi.Input[str]] = None,
                   output_file: Optional[pulumi.Input[str]] = 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)
    public static Output<GetImagesResult> getImages(GetImagesArgs args, InvokeOptions options)
    
    fn::invoke:
      function: ucloud:index/getImages:getImages
      arguments:
        # arguments dictionary

    The following arguments are supported:

    AvailabilityZone string
    Availability zone where images are located. such as: cn-bj2-02. You may refer to list of availability zone.
    Id string
    The ID of image.
    Ids List<string>

    A list of image IDs, all the images belong to this region will be retrieved if the ID is [].

    Note this argument conflicts with image_id.

    ImageId string

    The ID of image.

    Note this argument conflicts with ids.

    ImageType string
    The type of image. Possible values are: base as standard image, business as owned by market place, and custom as custom-image, all the image types will be retrieved by default.
    MostRecent bool
    If more than one result is returned, use the most recent image.
    NameRegex string
    A regex string to filter resulting images by name. (Such as: ^CentOS 7.[1-2] 64 means CentOS 7.1 of 64-bit operating system or CentOS 7.2 of 64-bit operating system, "^Ubuntu 16.04 64" means Ubuntu 16.04 of 64-bit operating system).
    OsType string
    The type of OS. Possible values are: linux and windows, all the OS types will be retrieved by default.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    AvailabilityZone string
    Availability zone where images are located. such as: cn-bj2-02. You may refer to list of availability zone.
    Id string
    The ID of image.
    Ids []string

    A list of image IDs, all the images belong to this region will be retrieved if the ID is [].

    Note this argument conflicts with image_id.

    ImageId string

    The ID of image.

    Note this argument conflicts with ids.

    ImageType string
    The type of image. Possible values are: base as standard image, business as owned by market place, and custom as custom-image, all the image types will be retrieved by default.
    MostRecent bool
    If more than one result is returned, use the most recent image.
    NameRegex string
    A regex string to filter resulting images by name. (Such as: ^CentOS 7.[1-2] 64 means CentOS 7.1 of 64-bit operating system or CentOS 7.2 of 64-bit operating system, "^Ubuntu 16.04 64" means Ubuntu 16.04 of 64-bit operating system).
    OsType string
    The type of OS. Possible values are: linux and windows, all the OS types will be retrieved by default.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    availabilityZone String
    Availability zone where images are located. such as: cn-bj2-02. You may refer to list of availability zone.
    id String
    The ID of image.
    ids List<String>

    A list of image IDs, all the images belong to this region will be retrieved if the ID is [].

    Note this argument conflicts with image_id.

    imageId String

    The ID of image.

    Note this argument conflicts with ids.

    imageType String
    The type of image. Possible values are: base as standard image, business as owned by market place, and custom as custom-image, all the image types will be retrieved by default.
    mostRecent Boolean
    If more than one result is returned, use the most recent image.
    nameRegex String
    A regex string to filter resulting images by name. (Such as: ^CentOS 7.[1-2] 64 means CentOS 7.1 of 64-bit operating system or CentOS 7.2 of 64-bit operating system, "^Ubuntu 16.04 64" means Ubuntu 16.04 of 64-bit operating system).
    osType String
    The type of OS. Possible values are: linux and windows, all the OS types will be retrieved by default.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    availabilityZone string
    Availability zone where images are located. such as: cn-bj2-02. You may refer to list of availability zone.
    id string
    The ID of image.
    ids string[]

    A list of image IDs, all the images belong to this region will be retrieved if the ID is [].

    Note this argument conflicts with image_id.

    imageId string

    The ID of image.

    Note this argument conflicts with ids.

    imageType string
    The type of image. Possible values are: base as standard image, business as owned by market place, and custom as custom-image, all the image types will be retrieved by default.
    mostRecent boolean
    If more than one result is returned, use the most recent image.
    nameRegex string
    A regex string to filter resulting images by name. (Such as: ^CentOS 7.[1-2] 64 means CentOS 7.1 of 64-bit operating system or CentOS 7.2 of 64-bit operating system, "^Ubuntu 16.04 64" means Ubuntu 16.04 of 64-bit operating system).
    osType string
    The type of OS. Possible values are: linux and windows, all the OS types will be retrieved by default.
    outputFile string
    File name where to save data source results (after running pulumi preview).
    availability_zone str
    Availability zone where images are located. such as: cn-bj2-02. You may refer to list of availability zone.
    id str
    The ID of image.
    ids Sequence[str]

    A list of image IDs, all the images belong to this region will be retrieved if the ID is [].

    Note this argument conflicts with image_id.

    image_id str

    The ID of image.

    Note this argument conflicts with ids.

    image_type str
    The type of image. Possible values are: base as standard image, business as owned by market place, and custom as custom-image, all the image types will be retrieved by default.
    most_recent bool
    If more than one result is returned, use the most recent image.
    name_regex str
    A regex string to filter resulting images by name. (Such as: ^CentOS 7.[1-2] 64 means CentOS 7.1 of 64-bit operating system or CentOS 7.2 of 64-bit operating system, "^Ubuntu 16.04 64" means Ubuntu 16.04 of 64-bit operating system).
    os_type str
    The type of OS. Possible values are: linux and windows, all the OS types will be retrieved by default.
    output_file str
    File name where to save data source results (after running pulumi preview).
    availabilityZone String
    Availability zone where images are located. such as: cn-bj2-02. You may refer to list of availability zone.
    id String
    The ID of image.
    ids List<String>

    A list of image IDs, all the images belong to this region will be retrieved if the ID is [].

    Note this argument conflicts with image_id.

    imageId String

    The ID of image.

    Note this argument conflicts with ids.

    imageType String
    The type of image. Possible values are: base as standard image, business as owned by market place, and custom as custom-image, all the image types will be retrieved by default.
    mostRecent Boolean
    If more than one result is returned, use the most recent image.
    nameRegex String
    A regex string to filter resulting images by name. (Such as: ^CentOS 7.[1-2] 64 means CentOS 7.1 of 64-bit operating system or CentOS 7.2 of 64-bit operating system, "^Ubuntu 16.04 64" means Ubuntu 16.04 of 64-bit operating system).
    osType String
    The type of OS. Possible values are: linux and windows, all the OS types will be retrieved by default.
    outputFile String
    File name where to save data source results (after running pulumi preview).

    getImages Result

    The following output properties are available:

    Id string
    The ID of image.
    Ids List<string>
    Images List<GetImagesImage>
    It is a nested type which documented below.
    TotalCount double
    Total number of images that satisfy the condition.
    AvailabilityZone string
    Availability zone where image is located.
    ImageId string
    ImageType string
    MostRecent bool
    NameRegex string
    OsType string
    The type of OS.
    OutputFile string
    Id string
    The ID of image.
    Ids []string
    Images []GetImagesImage
    It is a nested type which documented below.
    TotalCount float64
    Total number of images that satisfy the condition.
    AvailabilityZone string
    Availability zone where image is located.
    ImageId string
    ImageType string
    MostRecent bool
    NameRegex string
    OsType string
    The type of OS.
    OutputFile string
    id String
    The ID of image.
    ids List<String>
    images List<GetImagesImage>
    It is a nested type which documented below.
    totalCount Double
    Total number of images that satisfy the condition.
    availabilityZone String
    Availability zone where image is located.
    imageId String
    imageType String
    mostRecent Boolean
    nameRegex String
    osType String
    The type of OS.
    outputFile String
    id string
    The ID of image.
    ids string[]
    images GetImagesImage[]
    It is a nested type which documented below.
    totalCount number
    Total number of images that satisfy the condition.
    availabilityZone string
    Availability zone where image is located.
    imageId string
    imageType string
    mostRecent boolean
    nameRegex string
    osType string
    The type of OS.
    outputFile string
    id str
    The ID of image.
    ids Sequence[str]
    images Sequence[GetImagesImage]
    It is a nested type which documented below.
    total_count float
    Total number of images that satisfy the condition.
    availability_zone str
    Availability zone where image is located.
    image_id str
    image_type str
    most_recent bool
    name_regex str
    os_type str
    The type of OS.
    output_file str
    id String
    The ID of image.
    ids List<String>
    images List<Property Map>
    It is a nested type which documented below.
    totalCount Number
    Total number of images that satisfy the condition.
    availabilityZone String
    Availability zone where image is located.
    imageId String
    imageType String
    mostRecent Boolean
    nameRegex String
    osType String
    The type of OS.
    outputFile String

    Supporting Types

    GetImagesImage

    AvailabilityZone string
    Availability zone where images are located. such as: cn-bj2-02. You may refer to list of availability zone.
    CreateTime string
    The time of creation for image, formatted in RFC3339 time string.
    Description string
    The description of image if any.
    Features List<string>
    To identify if any particular feature belongs to the instance, the value is NetEnhnced as I/O enhanced instance for now.
    Id string
    The ID of image.
    Name string
    The name of image.
    OsName string
    The name of OS.
    OsType string
    The type of OS. Possible values are: linux and windows, all the OS types will be retrieved by default.
    Size double
    The size of image.
    Status string
    The status of image. Possible values are Available, Making and Unavailable.
    Type string
    The type of image.
    AvailabilityZone string
    Availability zone where images are located. such as: cn-bj2-02. You may refer to list of availability zone.
    CreateTime string
    The time of creation for image, formatted in RFC3339 time string.
    Description string
    The description of image if any.
    Features []string
    To identify if any particular feature belongs to the instance, the value is NetEnhnced as I/O enhanced instance for now.
    Id string
    The ID of image.
    Name string
    The name of image.
    OsName string
    The name of OS.
    OsType string
    The type of OS. Possible values are: linux and windows, all the OS types will be retrieved by default.
    Size float64
    The size of image.
    Status string
    The status of image. Possible values are Available, Making and Unavailable.
    Type string
    The type of image.
    availabilityZone String
    Availability zone where images are located. such as: cn-bj2-02. You may refer to list of availability zone.
    createTime String
    The time of creation for image, formatted in RFC3339 time string.
    description String
    The description of image if any.
    features List<String>
    To identify if any particular feature belongs to the instance, the value is NetEnhnced as I/O enhanced instance for now.
    id String
    The ID of image.
    name String
    The name of image.
    osName String
    The name of OS.
    osType String
    The type of OS. Possible values are: linux and windows, all the OS types will be retrieved by default.
    size Double
    The size of image.
    status String
    The status of image. Possible values are Available, Making and Unavailable.
    type String
    The type of image.
    availabilityZone string
    Availability zone where images are located. such as: cn-bj2-02. You may refer to list of availability zone.
    createTime string
    The time of creation for image, formatted in RFC3339 time string.
    description string
    The description of image if any.
    features string[]
    To identify if any particular feature belongs to the instance, the value is NetEnhnced as I/O enhanced instance for now.
    id string
    The ID of image.
    name string
    The name of image.
    osName string
    The name of OS.
    osType string
    The type of OS. Possible values are: linux and windows, all the OS types will be retrieved by default.
    size number
    The size of image.
    status string
    The status of image. Possible values are Available, Making and Unavailable.
    type string
    The type of image.
    availability_zone str
    Availability zone where images are located. such as: cn-bj2-02. You may refer to list of availability zone.
    create_time str
    The time of creation for image, formatted in RFC3339 time string.
    description str
    The description of image if any.
    features Sequence[str]
    To identify if any particular feature belongs to the instance, the value is NetEnhnced as I/O enhanced instance for now.
    id str
    The ID of image.
    name str
    The name of image.
    os_name str
    The name of OS.
    os_type str
    The type of OS. Possible values are: linux and windows, all the OS types will be retrieved by default.
    size float
    The size of image.
    status str
    The status of image. Possible values are Available, Making and Unavailable.
    type str
    The type of image.
    availabilityZone String
    Availability zone where images are located. such as: cn-bj2-02. You may refer to list of availability zone.
    createTime String
    The time of creation for image, formatted in RFC3339 time string.
    description String
    The description of image if any.
    features List<String>
    To identify if any particular feature belongs to the instance, the value is NetEnhnced as I/O enhanced instance for now.
    id String
    The ID of image.
    name String
    The name of image.
    osName String
    The name of OS.
    osType String
    The type of OS. Possible values are: linux and windows, all the OS types will be retrieved by default.
    size Number
    The size of image.
    status String
    The status of image. Possible values are Available, Making and Unavailable.
    type String
    The type of image.

    Package Details

    Repository
    ucloud ucloud/terraform-provider-ucloud
    License
    Notes
    This Pulumi package is based on the ucloud Terraform Provider.
    ucloud logo
    ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud