github.com/ves/terraform@v0.8.0-beta2/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  * `acl` - (Optional) The [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl) to apply. Defaults to "private".
    56  * `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.
    57  * `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.
    58  * `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.
    59  * `content_language` - (Optional) The language the content is in e.g. en-US or en-GB.
    60  * `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.
    61  * `storage_class` - (Optional) Specifies the desired [Storage Class](http://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html)
    62  for the object. Can be either "`STANDARD`", "`REDUCED_REDUNDANCY`", or "`STANDARD_IA`". Defaults to "`STANDARD`".
    63  * `etag` - (Optional) Used to trigger updates. The only meaningful value is `${md5(file("path/to/file"))}`.
    64  This attribute is not compatible with `kms_key_id`
    65  * `kms_key_id` - (Optional) Specifies the AWS KMS Key ID to use for object encryption.
    66  This value is a fully qualified **ARN** of the KMS Key. If using `aws_kms_key`,
    67  use the exported `arn` attribute:  
    68        `kms_key_id = "${aws_kms_key.foo.arn}"`
    69  
    70  Either `source` or `content` must be provided to specify the bucket content.
    71  These two arguments are mutually-exclusive.
    72  
    73  ## Attributes Reference
    74  
    75  The following attributes are exported
    76  
    77  * `id` - the `key` of the resource supplied above
    78  * `etag` - the ETag generated for the object (an MD5 sum of the object content).
    79  * `version_id` - A unique version ID value for the object, if bucket versioning
    80  is enabled.