1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. oss
  5. getBucketObjects
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

alicloud.oss.getBucketObjects

Explore with Pulumi AI

Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

This data source provides the objects of an OSS bucket.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const bucketObjectsDs = alicloud.oss.getBucketObjects({
    bucketName: "sample_bucket",
    keyRegex: "sample/sample_object.txt",
});
export const firstObjectKey = bucketObjectsDs.then(bucketObjectsDs => bucketObjectsDs.objects?.[0]?.key);
Copy
import pulumi
import pulumi_alicloud as alicloud

bucket_objects_ds = alicloud.oss.get_bucket_objects(bucket_name="sample_bucket",
    key_regex="sample/sample_object.txt")
pulumi.export("firstObjectKey", bucket_objects_ds.objects[0].key)
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/oss"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		bucketObjectsDs, err := oss.GetBucketObjects(ctx, &oss.GetBucketObjectsArgs{
			BucketName: "sample_bucket",
			KeyRegex:   pulumi.StringRef("sample/sample_object.txt"),
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("firstObjectKey", bucketObjectsDs.Objects[0].Key)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var bucketObjectsDs = AliCloud.Oss.GetBucketObjects.Invoke(new()
    {
        BucketName = "sample_bucket",
        KeyRegex = "sample/sample_object.txt",
    });

    return new Dictionary<string, object?>
    {
        ["firstObjectKey"] = bucketObjectsDs.Apply(getBucketObjectsResult => getBucketObjectsResult.Objects[0]?.Key),
    };
});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.oss.OssFunctions;
import com.pulumi.alicloud.oss.inputs.GetBucketObjectsArgs;
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 bucketObjectsDs = OssFunctions.getBucketObjects(GetBucketObjectsArgs.builder()
            .bucketName("sample_bucket")
            .keyRegex("sample/sample_object.txt")
            .build());

        ctx.export("firstObjectKey", bucketObjectsDs.applyValue(getBucketObjectsResult -> getBucketObjectsResult.objects()[0].key()));
    }
}
Copy
variables:
  bucketObjectsDs:
    fn::invoke:
      function: alicloud:oss:getBucketObjects
      arguments:
        bucketName: sample_bucket
        keyRegex: sample/sample_object.txt
outputs:
  firstObjectKey: ${bucketObjectsDs.objects[0].key}
Copy

Using getBucketObjects

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 getBucketObjects(args: GetBucketObjectsArgs, opts?: InvokeOptions): Promise<GetBucketObjectsResult>
function getBucketObjectsOutput(args: GetBucketObjectsOutputArgs, opts?: InvokeOptions): Output<GetBucketObjectsResult>
Copy
def get_bucket_objects(bucket_name: Optional[str] = None,
                       key_prefix: Optional[str] = None,
                       key_regex: Optional[str] = None,
                       output_file: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetBucketObjectsResult
def get_bucket_objects_output(bucket_name: Optional[pulumi.Input[str]] = None,
                       key_prefix: Optional[pulumi.Input[str]] = None,
                       key_regex: Optional[pulumi.Input[str]] = None,
                       output_file: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetBucketObjectsResult]
Copy
func GetBucketObjects(ctx *Context, args *GetBucketObjectsArgs, opts ...InvokeOption) (*GetBucketObjectsResult, error)
func GetBucketObjectsOutput(ctx *Context, args *GetBucketObjectsOutputArgs, opts ...InvokeOption) GetBucketObjectsResultOutput
Copy

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

public static class GetBucketObjects 
{
    public static Task<GetBucketObjectsResult> InvokeAsync(GetBucketObjectsArgs args, InvokeOptions? opts = null)
    public static Output<GetBucketObjectsResult> Invoke(GetBucketObjectsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetBucketObjectsResult> getBucketObjects(GetBucketObjectsArgs args, InvokeOptions options)
public static Output<GetBucketObjectsResult> getBucketObjects(GetBucketObjectsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: alicloud:oss/getBucketObjects:getBucketObjects
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

BucketName
This property is required.
Changes to this property will trigger replacement.
string
Name of the bucket that contains the objects to find.
KeyPrefix Changes to this property will trigger replacement. string
Filter results by the given key prefix (such as "path/to/folder/logs-").
KeyRegex Changes to this property will trigger replacement. string
A regex string to filter results by key.
OutputFile string
File name where to save data source results (after running pulumi preview).
BucketName
This property is required.
Changes to this property will trigger replacement.
string
Name of the bucket that contains the objects to find.
KeyPrefix Changes to this property will trigger replacement. string
Filter results by the given key prefix (such as "path/to/folder/logs-").
KeyRegex Changes to this property will trigger replacement. string
A regex string to filter results by key.
OutputFile string
File name where to save data source results (after running pulumi preview).
bucketName
This property is required.
Changes to this property will trigger replacement.
String
Name of the bucket that contains the objects to find.
keyPrefix Changes to this property will trigger replacement. String
Filter results by the given key prefix (such as "path/to/folder/logs-").
keyRegex Changes to this property will trigger replacement. String
A regex string to filter results by key.
outputFile String
File name where to save data source results (after running pulumi preview).
bucketName
This property is required.
Changes to this property will trigger replacement.
string
Name of the bucket that contains the objects to find.
keyPrefix Changes to this property will trigger replacement. string
Filter results by the given key prefix (such as "path/to/folder/logs-").
keyRegex Changes to this property will trigger replacement. string
A regex string to filter results by key.
outputFile string
File name where to save data source results (after running pulumi preview).
bucket_name
This property is required.
Changes to this property will trigger replacement.
str
Name of the bucket that contains the objects to find.
key_prefix Changes to this property will trigger replacement. str
Filter results by the given key prefix (such as "path/to/folder/logs-").
key_regex Changes to this property will trigger replacement. str
A regex string to filter results by key.
output_file str
File name where to save data source results (after running pulumi preview).
bucketName
This property is required.
Changes to this property will trigger replacement.
String
Name of the bucket that contains the objects to find.
keyPrefix Changes to this property will trigger replacement. String
Filter results by the given key prefix (such as "path/to/folder/logs-").
keyRegex Changes to this property will trigger replacement. String
A regex string to filter results by key.
outputFile String
File name where to save data source results (after running pulumi preview).

getBucketObjects Result

The following output properties are available:

BucketName string
Id string
The provider-assigned unique ID for this managed resource.
Objects List<Pulumi.AliCloud.Oss.Outputs.GetBucketObjectsObject>
A list of bucket objects. Each element contains the following attributes:
KeyPrefix string
KeyRegex string
OutputFile string
BucketName string
Id string
The provider-assigned unique ID for this managed resource.
Objects []GetBucketObjectsObject
A list of bucket objects. Each element contains the following attributes:
KeyPrefix string
KeyRegex string
OutputFile string
bucketName String
id String
The provider-assigned unique ID for this managed resource.
objects List<GetBucketObjectsObject>
A list of bucket objects. Each element contains the following attributes:
keyPrefix String
keyRegex String
outputFile String
bucketName string
id string
The provider-assigned unique ID for this managed resource.
objects GetBucketObjectsObject[]
A list of bucket objects. Each element contains the following attributes:
keyPrefix string
keyRegex string
outputFile string
bucket_name str
id str
The provider-assigned unique ID for this managed resource.
objects Sequence[GetBucketObjectsObject]
A list of bucket objects. Each element contains the following attributes:
key_prefix str
key_regex str
output_file str
bucketName String
id String
The provider-assigned unique ID for this managed resource.
objects List<Property Map>
A list of bucket objects. Each element contains the following attributes:
keyPrefix String
keyRegex String
outputFile String

Supporting Types

GetBucketObjectsObject

Acl This property is required. string
Object access control list. Possible values: default, private, public-read and public-read-write.
CacheControl This property is required. string
Caching behavior along the request/reply chain. Read RFC2616 Cache-Control for further details.
ContentDisposition This property is required. string
Presentational information for the object. Read RFC2616 Content-Disposition for further details.
ContentEncoding This property is required. string
Content encodings that have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field. Read RFC2616 Content-Encoding for further details.
ContentLength This property is required. string
Size of the object in bytes.
ContentMd5 This property is required. string
MD5 value of the content. Read MD5 for computing method.
ContentType This property is required. string
Standard MIME type describing the format of the object data, e.g. "application/octet-stream".
Etag This property is required. string
ETag generated for the object (MD5 sum of the object content).
Expires This property is required. string
Expiration date for the the request/response. Read RFC2616 Expires for further details.
Key This property is required. string
Object key.
LastModificationTime This property is required. string
Last modification time of the object.
ServerSideEncryption This property is required. string
Server-side encryption of the object in OSS. It can be empty or AES256.
SseKmsKeyId This property is required. string
If present, specifies the ID of the Key Management Service(KMS) master encryption key that was used for the object.
StorageClass This property is required. string
Object storage type. Possible values: Standard, IA, Archive and ColdArchive.
Acl This property is required. string
Object access control list. Possible values: default, private, public-read and public-read-write.
CacheControl This property is required. string
Caching behavior along the request/reply chain. Read RFC2616 Cache-Control for further details.
ContentDisposition This property is required. string
Presentational information for the object. Read RFC2616 Content-Disposition for further details.
ContentEncoding This property is required. string
Content encodings that have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field. Read RFC2616 Content-Encoding for further details.
ContentLength This property is required. string
Size of the object in bytes.
ContentMd5 This property is required. string
MD5 value of the content. Read MD5 for computing method.
ContentType This property is required. string
Standard MIME type describing the format of the object data, e.g. "application/octet-stream".
Etag This property is required. string
ETag generated for the object (MD5 sum of the object content).
Expires This property is required. string
Expiration date for the the request/response. Read RFC2616 Expires for further details.
Key This property is required. string
Object key.
LastModificationTime This property is required. string
Last modification time of the object.
ServerSideEncryption This property is required. string
Server-side encryption of the object in OSS. It can be empty or AES256.
SseKmsKeyId This property is required. string
If present, specifies the ID of the Key Management Service(KMS) master encryption key that was used for the object.
StorageClass This property is required. string
Object storage type. Possible values: Standard, IA, Archive and ColdArchive.
acl This property is required. String
Object access control list. Possible values: default, private, public-read and public-read-write.
cacheControl This property is required. String
Caching behavior along the request/reply chain. Read RFC2616 Cache-Control for further details.
contentDisposition This property is required. String
Presentational information for the object. Read RFC2616 Content-Disposition for further details.
contentEncoding This property is required. String
Content encodings that have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field. Read RFC2616 Content-Encoding for further details.
contentLength This property is required. String
Size of the object in bytes.
contentMd5 This property is required. String
MD5 value of the content. Read MD5 for computing method.
contentType This property is required. String
Standard MIME type describing the format of the object data, e.g. "application/octet-stream".
etag This property is required. String
ETag generated for the object (MD5 sum of the object content).
expires This property is required. String
Expiration date for the the request/response. Read RFC2616 Expires for further details.
key This property is required. String
Object key.
lastModificationTime This property is required. String
Last modification time of the object.
serverSideEncryption This property is required. String
Server-side encryption of the object in OSS. It can be empty or AES256.
sseKmsKeyId This property is required. String
If present, specifies the ID of the Key Management Service(KMS) master encryption key that was used for the object.
storageClass This property is required. String
Object storage type. Possible values: Standard, IA, Archive and ColdArchive.
acl This property is required. string
Object access control list. Possible values: default, private, public-read and public-read-write.
cacheControl This property is required. string
Caching behavior along the request/reply chain. Read RFC2616 Cache-Control for further details.
contentDisposition This property is required. string
Presentational information for the object. Read RFC2616 Content-Disposition for further details.
contentEncoding This property is required. string
Content encodings that have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field. Read RFC2616 Content-Encoding for further details.
contentLength This property is required. string
Size of the object in bytes.
contentMd5 This property is required. string
MD5 value of the content. Read MD5 for computing method.
contentType This property is required. string
Standard MIME type describing the format of the object data, e.g. "application/octet-stream".
etag This property is required. string
ETag generated for the object (MD5 sum of the object content).
expires This property is required. string
Expiration date for the the request/response. Read RFC2616 Expires for further details.
key This property is required. string
Object key.
lastModificationTime This property is required. string
Last modification time of the object.
serverSideEncryption This property is required. string
Server-side encryption of the object in OSS. It can be empty or AES256.
sseKmsKeyId This property is required. string
If present, specifies the ID of the Key Management Service(KMS) master encryption key that was used for the object.
storageClass This property is required. string
Object storage type. Possible values: Standard, IA, Archive and ColdArchive.
acl This property is required. str
Object access control list. Possible values: default, private, public-read and public-read-write.
cache_control This property is required. str
Caching behavior along the request/reply chain. Read RFC2616 Cache-Control for further details.
content_disposition This property is required. str
Presentational information for the object. Read RFC2616 Content-Disposition for further details.
content_encoding This property is required. str
Content encodings that have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field. Read RFC2616 Content-Encoding for further details.
content_length This property is required. str
Size of the object in bytes.
content_md5 This property is required. str
MD5 value of the content. Read MD5 for computing method.
content_type This property is required. str
Standard MIME type describing the format of the object data, e.g. "application/octet-stream".
etag This property is required. str
ETag generated for the object (MD5 sum of the object content).
expires This property is required. str
Expiration date for the the request/response. Read RFC2616 Expires for further details.
key This property is required. str
Object key.
last_modification_time This property is required. str
Last modification time of the object.
server_side_encryption This property is required. str
Server-side encryption of the object in OSS. It can be empty or AES256.
sse_kms_key_id This property is required. str
If present, specifies the ID of the Key Management Service(KMS) master encryption key that was used for the object.
storage_class This property is required. str
Object storage type. Possible values: Standard, IA, Archive and ColdArchive.
acl This property is required. String
Object access control list. Possible values: default, private, public-read and public-read-write.
cacheControl This property is required. String
Caching behavior along the request/reply chain. Read RFC2616 Cache-Control for further details.
contentDisposition This property is required. String
Presentational information for the object. Read RFC2616 Content-Disposition for further details.
contentEncoding This property is required. String
Content encodings that have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field. Read RFC2616 Content-Encoding for further details.
contentLength This property is required. String
Size of the object in bytes.
contentMd5 This property is required. String
MD5 value of the content. Read MD5 for computing method.
contentType This property is required. String
Standard MIME type describing the format of the object data, e.g. "application/octet-stream".
etag This property is required. String
ETag generated for the object (MD5 sum of the object content).
expires This property is required. String
Expiration date for the the request/response. Read RFC2616 Expires for further details.
key This property is required. String
Object key.
lastModificationTime This property is required. String
Last modification time of the object.
serverSideEncryption This property is required. String
Server-side encryption of the object in OSS. It can be empty or AES256.
sseKmsKeyId This property is required. String
If present, specifies the ID of the Key Management Service(KMS) master encryption key that was used for the object.
storageClass This property is required. String
Object storage type. Possible values: Standard, IA, Archive and ColdArchive.

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi