github.com/pmcatominey/terraform@v0.7.0-rc2.0.20160708105029-1401a52a5cc5/website/source/docs/providers/aws/r/s3_bucket_object.html.markdown (about)

     1  ---
     2  layout: "aws"
     3  page_title: "AWS: aws_s3_bucket_object"
     4  sidebar_current: "docs-aws-resource-s3-bucket-object"
     5  description: |-
     6    Provides a S3 bucket object resource.
     7  ---
     8  
     9  # aws\_s3\_bucket\_object
    10  
    11  Provides a S3 bucket object resource.
    12  
    13  ## Example Usage
    14  
    15  ### Uploading a file to a bucket
    16  
    17  ```
    18  resource "aws_s3_bucket_object" "object" {
    19  	bucket = "your_bucket_name"
    20  	key = "new_object_key"
    21  	source = "path/to/file"
    22  	etag = "${md5(file("path/to/file"))}"
    23  }
    24  ```
    25  
    26  ### Encrypting with KMS Key
    27  
    28  ```
    29  resource "aws_kms_key" "examplekms" {
    30    description             = "KMS key 1"
    31    deletion_window_in_days = 7
    32  }
    33  
    34  resource "aws_s3_bucket" "examplebucket" {
    35    bucket = "examplebuckettftest"
    36    acl    = "private"
    37  }
    38  
    39  resource "aws_s3_bucket_object" "examplebucket_object" {
    40    key        = "someobject"
    41    bucket     = "${aws_s3_bucket.examplebucket.bucket}"
    42    source     = "index.html"
    43    kms_key_id = "${aws_kms_key.examplekms.arn}"
    44  }
    45  ```
    46  
    47  ## Argument Reference
    48  
    49  The following arguments are supported:
    50  
    51  * `bucket` - (Required) The name of the bucket to put the file in.
    52  * `key` - (Required) The name of the object once it is in the bucket.
    53  * `source` - (Required) The path to the source file being uploaded to the bucket.
    54  * `content` - (Required unless `source` given) The literal content being uploaded to the bucket.
    55  * `cache_control` - (Optional) Specifies caching behavior along the request/reply chain Read [w3c cache_control](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9) for further details.
    56  * `content_disposition` - (Optional) Specifies presentational information for the object. Read [wc3 content_disposition](http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1) for further information.
    57  * `content_encoding` - (Optional) Specifies what content encodings 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 [w3c content encoding](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11) for further information.
    58  * `content_language` - (Optional) The language the content is in e.g. en-US or en-GB.
    59  * `content_type` - (Optional) A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input.
    60  * `etag` - (Optional) Used to trigger updates. The only meaningful value is `${md5(file("path/to/file"))}`. 
    61  This attribute is not compatible with `kms_key_id`
    62  * `kms_key_id` - (Optional) Specifies the AWS KMS Key ID to use for object encryption. 
    63  This value is a fully qualified **ARN** of the KMS Key. If using `aws_kms_key`,
    64  use the exported `arn` attribute:  
    65        `kms_key_id = "${aws_kms_key.foo.arn}"`
    66  
    67  Either `source` or `content` must be provided to specify the bucket content.
    68  These two arguments are mutually-exclusive.
    69  
    70  ## Attributes Reference
    71  
    72  The following attributes are exported
    73  
    74  * `id` - the `key` of the resource supplied above
    75  * `etag` - the ETag generated for the object (an MD5 sum of the object content).
    76  * `version_id` - A unique version ID value for the object, if bucket versioning
    77  is enabled.