Skip to content

googleStorageBucketObject

Creates a new object inside an existing bucket in Google cloud storage service (GCS). ACLs can be applied using the googleStorageObjectAcl resource. For more information see the official documentation and API.

Example Usage

Example creating a public object in an existing imageStore bucket.

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.storageBucketObject.StorageBucketObject(this, "picture", {
  bucket: "image-store",
  name: "butterfly01",
  source: "/images/nature/garden-tiger-moth.jpg",
});

Argument Reference

The following arguments are supported:

  • bucket - (Required) The name of the containing bucket.

  • name - (Required) The name of the object. If you're interpolating the name of this object, see outputName instead.

  • metadata - (Optional) User-provided metadata, in key/value pairs.

One of the following is required:

  • content - (Optional, Sensitive) Data as string to be uploaded. Must be defined if source is not. Note: The content field is marked as sensitive. To view the raw contents of the object, please define an output.

  • source - (Optional) A path to the data you want to upload. Must be defined if content is not.


  • cacheControl - (Optional) Cache-Control directive to specify caching behavior of object data. If omitted and object is accessible to all anonymous users, the default will be public, max-age=3600

  • contentDisposition - (Optional) Content-Disposition of the object data.

  • contentEncoding - (Optional) Content-Encoding of the object data.

  • contentLanguage - (Optional) Content-Language of the object data.

  • contentType - (Optional) Content-Type of the object data. Defaults to "application/octet-stream" or "text/plain; charset=utf-8".

  • customerEncryption - (Optional) Enables object encryption with Customer-Supplied Encryption Key (CSEK). [Google documentation about CSEK.](https://cloud.google.com/storage/docs/encryption/customer-supplied-keys) Structure is documented below.

  • eventBasedHold - (Optional) Whether an object is under event-based hold. Event-based hold is a way to retain objects until an event occurs, which is signified by the hold's release (i.e. this value is set to false). After being released (set to false), such objects will be subject to bucket-level retention (if any).

  • temporaryHold - (Optional) Whether an object is under temporary hold. While this flag is set to true, the object is protected against deletion and overwrites.

  • detectMd5Hash - (Optional) Detect changes to local file or changes made outside of Terraform to the file stored on the server. MD5 hash of the data, encoded using base64. This field is not present for composite objects. For more information about using the MD5 hash, see Hashes and ETags: Best Practices.

  • storageClass - (Optional) The StorageClass of the new bucket object. Supported values include: multiRegional, regional, nearline, coldline, archive. If not provided, this defaults to the bucket's default storage class or to a standard class.

  • kmsKeyName - (Optional) The resource name of the Cloud KMS key that will be used to encrypt the object.


The customerEncryption block supports:

  • encryptionAlgorithm - (Optional) Encryption algorithm. Default: AES256

  • encryptionKey - (Required) Base64 encoded Customer-Supplied Encryption Key.

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • crc32C - (Computed) Base 64 CRC32 hash of the uploaded data.

  • md5Hash - (Computed) Base 64 MD5 hash of the uploaded data.

  • selfLink - (Computed) A url reference to this object.

  • outputName - (Computed) The name of the object. Use this field in interpolations with googleStorageObjectAcl to recreate googleStorageObjectAcl resources when your googleStorageBucketObject is recreated.

  • mediaLink - (Computed) A url reference to download this object.

Timeouts

This resource provides the following Timeouts configuration options: configuration options:

  • create - Default is 4 minutes.
  • update - Default is 4 minutes.
  • delete - Default is 4 minutes.

Import

This resource does not support import.