github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/website/source/docs/providers/aws/d/s3_bucket_object.html.markdown (about)

     1  ---
     2  layout: "aws"
     3  page_title: "AWS: aws_s3_bucket_object"
     4  sidebar_current: "docs-aws-datasource-s3-bucket-object"
     5  description: |-
     6      Provides metadata and optionally content of an S3 object
     7  ---
     8  
     9  # aws\_s3\_bucket\_object
    10  
    11  The S3 object data source allows access to the metadata and
    12  _optionally_ (see below) content of an object stored inside S3 bucket.
    13  
    14  ~> **Note:** The content of an object (`body` field) is available only for objects which have a human-readable `Content-Type` (`text/*` and `application/json`). This is to prevent printing unsafe characters and potentially downloading large amount of data which would be thrown away in favour of metadata.
    15  
    16  ## Example Usage
    17  
    18  ```hcl
    19  data "aws_s3_bucket_object" "lambda" {
    20    bucket = "my-lambda-functions"
    21    key    = "hello-world.zip"
    22  }
    23  
    24  resource "aws_iam_role" "iam_for_lambda" {
    25    name = "iam_for_lambda"
    26  
    27    assume_role_policy = <<EOF
    28  {
    29    "Version": "2012-10-17",
    30    "Statement": [
    31      {
    32        "Action": "sts:AssumeRole",
    33        "Principal": {
    34          "Service": "lambda.amazonaws.com"
    35        },
    36        "Effect": "Allow",
    37        "Sid": ""
    38      }
    39    ]
    40  }
    41  EOF
    42  }
    43  
    44  resource "aws_lambda_function" "test_lambda" {
    45    s3_bucket         = "${data.aws_s3_bucket_object.lambda.bucket}"
    46    s3_key            = "${data.aws_s3_bucket_object.lambda.key}"
    47    s3_object_version = "${data.aws_s3_bucket_object.lambda.version_id}"
    48    function_name     = "lambda_function_name"
    49    role              = "${aws_iam_role.iam_for_lambda.arn}"
    50    handler           = "exports.test"
    51  }
    52  ```
    53  
    54  ## Argument Reference
    55  
    56  The following arguments are supported:
    57  
    58  * `bucket` - (Required) The name of the bucket to read the object from
    59  * `key` - (Required) The full path to the object inside the bucket
    60  * `version_id` - (Optional) Specific version ID of the object returned (defaults to latest version)
    61  
    62  ## Attributes Reference
    63  
    64  The following attributes are exported:
    65  
    66  * `body` - Object data (see **limitations above** to understand cases in which this field is actually available)
    67  * `cache_control` - Specifies caching behavior along the request/reply chain.
    68  * `content_disposition` - Specifies presentational information for the object.
    69  * `content_encoding` - 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.
    70  * `content_language` - The language the content is in.
    71  * `content_length` - Size of the body in bytes.
    72  * `content_type` - A standard MIME type describing the format of the object data.
    73  * `etag` - [ETag](https://en.wikipedia.org/wiki/HTTP_ETag) generated for the object (an MD5 sum of the object content in case it's not encrypted)
    74  * `expiration` - If the object expiration is configured (see [object lifecycle management](http://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html)), the field includes this header. It includes the expiry-date and rule-id key value pairs providing object expiration information. The value of the rule-id is URL encoded.
    75  * `expires` - The date and time at which the object is no longer cacheable.
    76  * `last_modified` - Last modified date of the object in RFC1123 format (e.g. `Mon, 02 Jan 2006 15:04:05 MST`)
    77  * `metadata` - A map of metadata stored with the object in S3
    78  * `server_side_encryption` - If the object is stored using server-side encryption (KMS or Amazon S3-managed encryption key), this field includes the chosen encryption and algorithm used.
    79  * `sse_kms_key_id` - If present, specifies the ID of the Key Management Service (KMS) master encryption key that was used for the object.
    80  * `storage_class` - [Storage class](http://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html) information of the object. Available for all objects except for `Standard` storage class objects.
    81  * `version_id` - The latest version ID of the object returned.
    82  * `website_redirect_location` - If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata.
    83  * `tags`  - A mapping of tags assigned to the object.