github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/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  ```hcl
    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  ```hcl
    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  ### Server Side Encryption with S3 Default Master Key
    48  
    49  ```hcl
    50  resource "aws_s3_bucket" "examplebucket" {
    51    bucket = "examplebuckettftest"
    52    acl    = "private"
    53  }
    54  
    55  resource "aws_s3_bucket_object" "examplebucket_object" {
    56    key                    = "someobject"
    57    bucket                 = "${aws_s3_bucket.examplebucket.bucket}"
    58    source                 = "index.html"
    59    server_side_encryption = "aws:kms"
    60  }
    61  ```
    62  
    63  ## Argument Reference
    64  
    65  The following arguments are supported:
    66  
    67  * `bucket` - (Required) The name of the bucket to put the file in.
    68  * `key` - (Required) The name of the object once it is in the bucket.
    69  * `source` - (Required) The path to the source file being uploaded to the bucket.
    70  * `content` - (Required unless `source` given) The literal content being uploaded to the bucket.
    71  * `acl` - (Optional) The [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl) to apply. Defaults to "private".
    72  * `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.
    73  * `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.
    74  * `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.
    75  * `content_language` - (Optional) The language the content is in e.g. en-US or en-GB.
    76  * `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.
    77  * `storage_class` - (Optional) Specifies the desired [Storage Class](http://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html)
    78  for the object. Can be either "`STANDARD`", "`REDUCED_REDUNDANCY`", or "`STANDARD_IA`". Defaults to "`STANDARD`".
    79  * `etag` - (Optional) Used to trigger updates. The only meaningful value is `${md5(file("path/to/file"))}`.
    80  This attribute is not compatible with `kms_key_id`.
    81  * `server_side_encryption` - (Optional) Specifies server-side encryption of the object in S3. Valid values are "`AES256`" and "`aws:kms`".
    82  * `kms_key_id` - (Optional) Specifies the AWS KMS Key ARN to use for object encryption.
    83  This value is a fully qualified **ARN** of the KMS Key. If using `aws_kms_key`,
    84  use the exported `arn` attribute:
    85        `kms_key_id = "${aws_kms_key.foo.arn}"`
    86  * `tags` - (Optional) A mapping of tags to assign to the object.
    87  
    88  Either `source` or `content` must be provided to specify the bucket content.
    89  These two arguments are mutually-exclusive.
    90  
    91  ## Attributes Reference
    92  
    93  The following attributes are exported
    94  
    95  * `id` - the `key` of the resource supplied above
    96  * `etag` - the ETag generated for the object (an MD5 sum of the object content).
    97  * `version_id` - A unique version ID value for the object, if bucket versioning
    98  is enabled.