2015-09-03 18:47:51 +00:00
---
layout: "google"
page_title: "Google: google_storage_bucket_object"
2015-10-23 14:10:41 +00:00
sidebar_current: "docs-google-storage-bucket-object"
2015-09-03 18:47:51 +00:00
description: |-
Creates a new object inside a specified bucket
---
# google\_storage\_bucket\_object
2017-06-06 23:08:45 +00:00
Creates a new object inside an existing bucket in Google cloud storage service (GCS).
[ACLs ](https://cloud.google.com/storage/docs/access-control/lists ) can be applied using the `google_storage_object_acl` resource.
For more information see
[the official documentation ](https://cloud.google.com/storage/docs/key-terms#objects )
and
[API ](https://cloud.google.com/storage/docs/json_api/v1/objects ).
2015-09-03 18:47:51 +00:00
## Example Usage
Example creating a public object in an existing `image-store` bucket.
2017-04-17 10:17:54 +00:00
```hcl
2015-09-03 18:47:51 +00:00
resource "google_storage_bucket_object" "picture" {
2016-04-10 21:34:15 +00:00
name = "butterfly01"
source = "/images/nature/garden-tiger-moth.jpg"
bucket = "image-store"
2015-09-03 18:47:51 +00:00
}
```
## Argument Reference
The following arguments are supported:
* `bucket` - (Required) The name of the containing bucket.
2015-11-12 21:20:08 +00:00
2016-04-10 21:34:15 +00:00
* `name` - (Required) The name of the object.
2017-05-08 23:35:47 +00:00
One of the following is required:
2015-11-12 21:20:08 +00:00
* `content` - (Optional) Data as `string` to be uploaded. Must be defined if
2016-04-10 21:34:15 +00:00
`source` is not.
2015-11-12 21:20:08 +00:00
2017-05-08 23:35:47 +00:00
* `source` - (Optional) A path to the data you want to upload. Must be defined
if `content` is not.
- - -
* `cache_control` - (Optional) [Cache-Control ](https://tools.ietf.org/html/rfc7234#section-5.2 )
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
* `content_disposition` - (Optional) [Content-Disposition ](https://tools.ietf.org/html/rfc6266 ) of the object data.
* `content_encoding` - (Optional) [Content-Encoding ](https://tools.ietf.org/html/rfc7231#section-3.1.2.2 ) of the object data.
* `content_language` - (Optional) [Content-Language ](https://tools.ietf.org/html/rfc7231#section-3.1.3.2 ) of the object data.
* `content_type` - (Optional) [Content-Type ](https://tools.ietf.org/html/rfc7231#section-3.1.1.5 ) of the object data. Defaults to "application/octet-stream" or "text/plain; charset=utf-8".
2016-03-31 10:37:17 +00:00
* `predefined_acl` - (Optional, Deprecated) The [canned GCS ACL ](https://cloud.google.com/storage/docs/access-control#predefined-acl ) apply. Please switch
2015-09-16 18:46:46 +00:00
to `google_storage_object_acl.predefined_acl` .
2015-09-03 18:47:51 +00:00
2017-05-08 23:35:47 +00:00
* `storage_class` - (Optional) The [StorageClass ](https://cloud.google.com/storage/docs/storage-classes ) of the new bucket object.
Supported values include: `MULTI_REGIONAL` , `REGIONAL` , `NEARLINE` , `COLDLINE` . If not provided, this defaults to the bucket's default
storage class or to a [standard ](https://cloud.google.com/storage/docs/storage-classes#standard ) class.
2015-09-03 18:47:51 +00:00
2016-04-10 21:34:15 +00:00
## Attributes Reference
In addition to the arguments listed above, the following computed attributes are
exported:
2015-11-12 21:20:08 +00:00
2015-09-03 18:47:51 +00:00
* `crc32c` - (Computed) Base 64 CRC32 hash of the uploaded data.
2016-04-10 21:34:15 +00:00
* `md5hash` - (Computed) Base 64 MD5 hash of the uploaded data.