1. Packages
  2. Ibm Provider
  3. API Docs
  4. getCosBucketObject
ibm 1.78.0 published on Wednesday, Apr 30, 2025 by ibm-cloud

ibm.getCosBucketObject

Explore with Pulumi AI

ibm logo
ibm 1.78.0 published on Wednesday, Apr 30, 2025 by ibm-cloud

    Retrieves information of an object in IBM Cloud Object Storage bucket. For more information, about an IBM Cloud Object Storage bucket, see Create some buckets to store your data.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as ibm from "@pulumi/ibm";
    
    const cosGroup = ibm.getResourceGroup({
        name: "cos-resource-group",
    });
    const cosInstance = cosGroup.then(cosGroup => ibm.getResourceInstance({
        name: "cos-instance",
        resourceGroupId: cosGroup.id,
        service: "cloud-object-storage",
    }));
    const cosBucket = cosInstance.then(cosInstance => ibm.getCosBucket({
        resourceInstanceId: cosInstance.id,
        bucketName: "my-bucket",
        bucketType: "region_location",
        bucketRegion: "us-east",
    }));
    const cosObject = Promise.all([cosBucket, cosBucket]).then(([cosBucket, cosBucket1]) => ibm.getCosBucketObject({
        bucketCrn: cosBucket.crn,
        bucketLocation: cosBucket1.bucketRegion,
        key: "object.json",
    }));
    
    import pulumi
    import pulumi_ibm as ibm
    
    cos_group = ibm.get_resource_group(name="cos-resource-group")
    cos_instance = ibm.get_resource_instance(name="cos-instance",
        resource_group_id=cos_group.id,
        service="cloud-object-storage")
    cos_bucket = ibm.get_cos_bucket(resource_instance_id=cos_instance.id,
        bucket_name="my-bucket",
        bucket_type="region_location",
        bucket_region="us-east")
    cos_object = ibm.get_cos_bucket_object(bucket_crn=cos_bucket.crn,
        bucket_location=cos_bucket.bucket_region,
        key="object.json")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ibm/ibm"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		cosGroup, err := ibm.LookupResourceGroup(ctx, &ibm.LookupResourceGroupArgs{
    			Name: pulumi.StringRef("cos-resource-group"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		cosInstance, err := ibm.LookupResourceInstance(ctx, &ibm.LookupResourceInstanceArgs{
    			Name:            pulumi.StringRef("cos-instance"),
    			ResourceGroupId: pulumi.StringRef(cosGroup.Id),
    			Service:         pulumi.StringRef("cloud-object-storage"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		cosBucket, err := ibm.LookupCosBucket(ctx, &ibm.LookupCosBucketArgs{
    			ResourceInstanceId: cosInstance.Id,
    			BucketName:         "my-bucket",
    			BucketType:         pulumi.StringRef("region_location"),
    			BucketRegion:       pulumi.StringRef("us-east"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = ibm.LookupCosBucketObject(ctx, &ibm.LookupCosBucketObjectArgs{
    			BucketCrn:      cosBucket.Crn,
    			BucketLocation: cosBucket.BucketRegion,
    			Key:            "object.json",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ibm = Pulumi.Ibm;
    
    return await Deployment.RunAsync(() => 
    {
        var cosGroup = Ibm.GetResourceGroup.Invoke(new()
        {
            Name = "cos-resource-group",
        });
    
        var cosInstance = Ibm.GetResourceInstance.Invoke(new()
        {
            Name = "cos-instance",
            ResourceGroupId = cosGroup.Apply(getResourceGroupResult => getResourceGroupResult.Id),
            Service = "cloud-object-storage",
        });
    
        var cosBucket = Ibm.GetCosBucket.Invoke(new()
        {
            ResourceInstanceId = cosInstance.Apply(getResourceInstanceResult => getResourceInstanceResult.Id),
            BucketName = "my-bucket",
            BucketType = "region_location",
            BucketRegion = "us-east",
        });
    
        var cosObject = Ibm.GetCosBucketObject.Invoke(new()
        {
            BucketCrn = cosBucket.Apply(getCosBucketResult => getCosBucketResult.Crn),
            BucketLocation = cosBucket.Apply(getCosBucketResult => getCosBucketResult.BucketRegion),
            Key = "object.json",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ibm.IbmFunctions;
    import com.pulumi.ibm.inputs.GetResourceGroupArgs;
    import com.pulumi.ibm.inputs.GetResourceInstanceArgs;
    import com.pulumi.ibm.inputs.GetCosBucketArgs;
    import com.pulumi.ibm.inputs.GetCosBucketObjectArgs;
    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 cosGroup = IbmFunctions.getResourceGroup(GetResourceGroupArgs.builder()
                .name("cos-resource-group")
                .build());
    
            final var cosInstance = IbmFunctions.getResourceInstance(GetResourceInstanceArgs.builder()
                .name("cos-instance")
                .resourceGroupId(cosGroup.applyValue(getResourceGroupResult -> getResourceGroupResult.id()))
                .service("cloud-object-storage")
                .build());
    
            final var cosBucket = IbmFunctions.getCosBucket(GetCosBucketArgs.builder()
                .resourceInstanceId(cosInstance.applyValue(getResourceInstanceResult -> getResourceInstanceResult.id()))
                .bucketName("my-bucket")
                .bucketType("region_location")
                .bucketRegion("us-east")
                .build());
    
            final var cosObject = IbmFunctions.getCosBucketObject(GetCosBucketObjectArgs.builder()
                .bucketCrn(cosBucket.applyValue(getCosBucketResult -> getCosBucketResult.crn()))
                .bucketLocation(cosBucket.applyValue(getCosBucketResult -> getCosBucketResult.bucketRegion()))
                .key("object.json")
                .build());
    
        }
    }
    
    variables:
      cosGroup:
        fn::invoke:
          function: ibm:getResourceGroup
          arguments:
            name: cos-resource-group
      cosInstance:
        fn::invoke:
          function: ibm:getResourceInstance
          arguments:
            name: cos-instance
            resourceGroupId: ${cosGroup.id}
            service: cloud-object-storage
      cosBucket:
        fn::invoke:
          function: ibm:getCosBucket
          arguments:
            resourceInstanceId: ${cosInstance.id}
            bucketName: my-bucket
            bucketType: region_location
            bucketRegion: us-east
      cosObject:
        fn::invoke:
          function: ibm:getCosBucketObject
          arguments:
            bucketCrn: ${cosBucket.crn}
            bucketLocation: ${cosBucket.bucketRegion}
            key: object.json
    

    Using getCosBucketObject

    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 getCosBucketObject(args: GetCosBucketObjectArgs, opts?: InvokeOptions): Promise<GetCosBucketObjectResult>
    function getCosBucketObjectOutput(args: GetCosBucketObjectOutputArgs, opts?: InvokeOptions): Output<GetCosBucketObjectResult>
    def get_cos_bucket_object(bucket_crn: Optional[str] = None,
                              bucket_location: Optional[str] = None,
                              endpoint_type: Optional[str] = None,
                              id: Optional[str] = None,
                              key: Optional[str] = None,
                              opts: Optional[InvokeOptions] = None) -> GetCosBucketObjectResult
    def get_cos_bucket_object_output(bucket_crn: Optional[pulumi.Input[str]] = None,
                              bucket_location: Optional[pulumi.Input[str]] = None,
                              endpoint_type: Optional[pulumi.Input[str]] = None,
                              id: Optional[pulumi.Input[str]] = None,
                              key: Optional[pulumi.Input[str]] = None,
                              opts: Optional[InvokeOptions] = None) -> Output[GetCosBucketObjectResult]
    func LookupCosBucketObject(ctx *Context, args *LookupCosBucketObjectArgs, opts ...InvokeOption) (*LookupCosBucketObjectResult, error)
    func LookupCosBucketObjectOutput(ctx *Context, args *LookupCosBucketObjectOutputArgs, opts ...InvokeOption) LookupCosBucketObjectResultOutput

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

    public static class GetCosBucketObject 
    {
        public static Task<GetCosBucketObjectResult> InvokeAsync(GetCosBucketObjectArgs args, InvokeOptions? opts = null)
        public static Output<GetCosBucketObjectResult> Invoke(GetCosBucketObjectInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetCosBucketObjectResult> getCosBucketObject(GetCosBucketObjectArgs args, InvokeOptions options)
    public static Output<GetCosBucketObjectResult> getCosBucketObject(GetCosBucketObjectArgs args, InvokeOptions options)
    
    fn::invoke:
      function: ibm:index/getCosBucketObject:getCosBucketObject
      arguments:
        # arguments dictionary

    The following arguments are supported:

    BucketCrn string
    The CRN of the COS bucket.
    BucketLocation string
    The location of the COS bucket.
    Key string
    The name of an object in the COS bucket.
    EndpointType string
    The type of endpoint used to access COS. Accepted values: public, private, or direct. Default value is public.
    Id string
    (String) The ID of an object.
    BucketCrn string
    The CRN of the COS bucket.
    BucketLocation string
    The location of the COS bucket.
    Key string
    The name of an object in the COS bucket.
    EndpointType string
    The type of endpoint used to access COS. Accepted values: public, private, or direct. Default value is public.
    Id string
    (String) The ID of an object.
    bucketCrn String
    The CRN of the COS bucket.
    bucketLocation String
    The location of the COS bucket.
    key String
    The name of an object in the COS bucket.
    endpointType String
    The type of endpoint used to access COS. Accepted values: public, private, or direct. Default value is public.
    id String
    (String) The ID of an object.
    bucketCrn string
    The CRN of the COS bucket.
    bucketLocation string
    The location of the COS bucket.
    key string
    The name of an object in the COS bucket.
    endpointType string
    The type of endpoint used to access COS. Accepted values: public, private, or direct. Default value is public.
    id string
    (String) The ID of an object.
    bucket_crn str
    The CRN of the COS bucket.
    bucket_location str
    The location of the COS bucket.
    key str
    The name of an object in the COS bucket.
    endpoint_type str
    The type of endpoint used to access COS. Accepted values: public, private, or direct. Default value is public.
    id str
    (String) The ID of an object.
    bucketCrn String
    The CRN of the COS bucket.
    bucketLocation String
    The location of the COS bucket.
    key String
    The name of an object in the COS bucket.
    endpointType String
    The type of endpoint used to access COS. Accepted values: public, private, or direct. Default value is public.
    id String
    (String) The ID of an object.

    getCosBucketObject Result

    The following output properties are available:

    Body string
    (String) Literal string value of an object content. Only supported for text/* and application/json content types.
    BucketCrn string
    BucketLocation string
    ContentLength double
    (String) A standard MIME type describing the format of an object data.
    ContentType string
    (String) A standard MIME type describing the format of an object data.
    Etag string
    (String) Computed MD5 hexdigest of an object content.
    Id string
    (String) The ID of an object.
    Key string
    LastModified string
    (Timestamp) Last modified date of an object in a GMT formatted date.
    ObjectLockLegalHoldStatus string
    (String) If the value of this attribute is ON, then the object cannot be deleted from the COS bucket.

      • website_redirect - (String) If this value is set then incoming request will be redirected to the set value..
    ObjectLockMode string
    (String) This is the retention mode for an object.
    ObjectLockRetainUntilDate string
    (String) A date after which the object can be deleted from the COS bucket.
    ObjectSqlUrl string
    (String) Access the object using an SQL Query instance. The SQL URL is a reference URL used inside an SQL statement. The reference URL is used to perform queries against objects storing structured data.
    VersionId string
    WebsiteRedirect string
    EndpointType string
    Body string
    (String) Literal string value of an object content. Only supported for text/* and application/json content types.
    BucketCrn string
    BucketLocation string
    ContentLength float64
    (String) A standard MIME type describing the format of an object data.
    ContentType string
    (String) A standard MIME type describing the format of an object data.
    Etag string
    (String) Computed MD5 hexdigest of an object content.
    Id string
    (String) The ID of an object.
    Key string
    LastModified string
    (Timestamp) Last modified date of an object in a GMT formatted date.
    ObjectLockLegalHoldStatus string
    (String) If the value of this attribute is ON, then the object cannot be deleted from the COS bucket.

      • website_redirect - (String) If this value is set then incoming request will be redirected to the set value..
    ObjectLockMode string
    (String) This is the retention mode for an object.
    ObjectLockRetainUntilDate string
    (String) A date after which the object can be deleted from the COS bucket.
    ObjectSqlUrl string
    (String) Access the object using an SQL Query instance. The SQL URL is a reference URL used inside an SQL statement. The reference URL is used to perform queries against objects storing structured data.
    VersionId string
    WebsiteRedirect string
    EndpointType string
    body String
    (String) Literal string value of an object content. Only supported for text/* and application/json content types.
    bucketCrn String
    bucketLocation String
    contentLength Double
    (String) A standard MIME type describing the format of an object data.
    contentType String
    (String) A standard MIME type describing the format of an object data.
    etag String
    (String) Computed MD5 hexdigest of an object content.
    id String
    (String) The ID of an object.
    key String
    lastModified String
    (Timestamp) Last modified date of an object in a GMT formatted date.
    objectLockLegalHoldStatus String
    (String) If the value of this attribute is ON, then the object cannot be deleted from the COS bucket.

      • website_redirect - (String) If this value is set then incoming request will be redirected to the set value..
    objectLockMode String
    (String) This is the retention mode for an object.
    objectLockRetainUntilDate String
    (String) A date after which the object can be deleted from the COS bucket.
    objectSqlUrl String
    (String) Access the object using an SQL Query instance. The SQL URL is a reference URL used inside an SQL statement. The reference URL is used to perform queries against objects storing structured data.
    versionId String
    websiteRedirect String
    endpointType String
    body string
    (String) Literal string value of an object content. Only supported for text/* and application/json content types.
    bucketCrn string
    bucketLocation string
    contentLength number
    (String) A standard MIME type describing the format of an object data.
    contentType string
    (String) A standard MIME type describing the format of an object data.
    etag string
    (String) Computed MD5 hexdigest of an object content.
    id string
    (String) The ID of an object.
    key string
    lastModified string
    (Timestamp) Last modified date of an object in a GMT formatted date.
    objectLockLegalHoldStatus string
    (String) If the value of this attribute is ON, then the object cannot be deleted from the COS bucket.

      • website_redirect - (String) If this value is set then incoming request will be redirected to the set value..
    objectLockMode string
    (String) This is the retention mode for an object.
    objectLockRetainUntilDate string
    (String) A date after which the object can be deleted from the COS bucket.
    objectSqlUrl string
    (String) Access the object using an SQL Query instance. The SQL URL is a reference URL used inside an SQL statement. The reference URL is used to perform queries against objects storing structured data.
    versionId string
    websiteRedirect string
    endpointType string
    body str
    (String) Literal string value of an object content. Only supported for text/* and application/json content types.
    bucket_crn str
    bucket_location str
    content_length float
    (String) A standard MIME type describing the format of an object data.
    content_type str
    (String) A standard MIME type describing the format of an object data.
    etag str
    (String) Computed MD5 hexdigest of an object content.
    id str
    (String) The ID of an object.
    key str
    last_modified str
    (Timestamp) Last modified date of an object in a GMT formatted date.
    object_lock_legal_hold_status str
    (String) If the value of this attribute is ON, then the object cannot be deleted from the COS bucket.

      • website_redirect - (String) If this value is set then incoming request will be redirected to the set value..
    object_lock_mode str
    (String) This is the retention mode for an object.
    object_lock_retain_until_date str
    (String) A date after which the object can be deleted from the COS bucket.
    object_sql_url str
    (String) Access the object using an SQL Query instance. The SQL URL is a reference URL used inside an SQL statement. The reference URL is used to perform queries against objects storing structured data.
    version_id str
    website_redirect str
    endpoint_type str
    body String
    (String) Literal string value of an object content. Only supported for text/* and application/json content types.
    bucketCrn String
    bucketLocation String
    contentLength Number
    (String) A standard MIME type describing the format of an object data.
    contentType String
    (String) A standard MIME type describing the format of an object data.
    etag String
    (String) Computed MD5 hexdigest of an object content.
    id String
    (String) The ID of an object.
    key String
    lastModified String
    (Timestamp) Last modified date of an object in a GMT formatted date.
    objectLockLegalHoldStatus String
    (String) If the value of this attribute is ON, then the object cannot be deleted from the COS bucket.

      • website_redirect - (String) If this value is set then incoming request will be redirected to the set value..
    objectLockMode String
    (String) This is the retention mode for an object.
    objectLockRetainUntilDate String
    (String) A date after which the object can be deleted from the COS bucket.
    objectSqlUrl String
    (String) Access the object using an SQL Query instance. The SQL URL is a reference URL used inside an SQL statement. The reference URL is used to perform queries against objects storing structured data.
    versionId String
    websiteRedirect String
    endpointType String

    Package Details

    Repository
    ibm ibm-cloud/terraform-provider-ibm
    License
    Notes
    This Pulumi package is based on the ibm Terraform Provider.
    ibm logo
    ibm 1.78.0 published on Wednesday, Apr 30, 2025 by ibm-cloud