github.com/adrian-bl/terraform@v0.7.0-rc2.0.20160705220747-de0a34fc3517/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 ``` 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 assume_role_policy = <<EOF 27 { 28 "Version": "2012-10-17", 29 "Statement": [ 30 { 31 "Action": "sts:AssumeRole", 32 "Principal": { 33 "Service": "lambda.amazonaws.com" 34 }, 35 "Effect": "Allow", 36 "Sid": "" 37 } 38 ] 39 } 40 EOF 41 } 42 43 resource "aws_lambda_function" "test_lambda" { 44 s3_bucket = "${data.aws_s3_bucket_object.lambda.bucket}" 45 s3_key = "${data.aws_s3_bucket_object.lambda.key}" 46 s3_object_version = "${data.aws_s3_bucket_object.lambda.version_id}" 47 function_name = "lambda_function_name" 48 role = "${aws_iam_role.iam_for_lambda.arn}" 49 handler = "exports.test" 50 } 51 ``` 52 53 ## Argument Reference 54 55 The following arguments are supported: 56 57 * `bucket` - (Required) The name of the bucket to read the object from 58 * `key` - (Required) The full path to the object inside the bucket 59 * `version_id` - (Optional) Specific version ID of the object returned (defaults to latest version) 60 61 ## Attributes Reference 62 63 The following attributes are exported: 64 65 * `body` - Object data (see **limitations above** to understand cases in which this field is actually available) 66 * `cache_control` - Specifies caching behavior along the request/reply chain. 67 * `content_disposition` - Specifies presentational information for the object. 68 * `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. 69 * `content_language` - The language the content is in. 70 * `content_length` - Size of the body in bytes. 71 * `content_type` - A standard MIME type describing the format of the object data. 72 * `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) 73 * `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. 74 * `expires` - The date and time at which the object is no longer cacheable. 75 * `last_modified` - Last modified date of the object in RFC1123 format (e.g. `Mon, 02 Jan 2006 15:04:05 MST`) 76 * `metadata` - A map of metadata stored with the object in S3 77 * `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. 78 * `sse_kms_key_id` - If present, specifies the ID of the Key Management Service (KMS) master encryption key that was used for the object. 79 * `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. 80 * `version_id` - The latest version ID of the object returned. 81 * `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.