FEATURES PRICING ABOUT DOCS LOGIN

aws_s3_bucket_object

The S3 object data source allows access to the metadata and optionally (see below) content of an object stored inside S3 bucket.

~> 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.

Example Usage

data "aws_s3_bucket_object" "lambda" {
    bucket = "my-lambda-functions"
    key = "hello-world.zip"
}

resource "aws_iam_role" "iam_for_lambda" {
    name = "iam_for_lambda"
    assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "lambda.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
EOF
}

resource "aws_lambda_function" "test_lambda" {
    s3_bucket = "${data.aws_s3_bucket_object.lambda.bucket}"
    s3_key = "${data.aws_s3_bucket_object.lambda.key}"
    s3_object_version = "${data.aws_s3_bucket_object.lambda.version_id}"
    function_name = "lambda_function_name"
    role = "${aws_iam_role.iam_for_lambda.arn}"
    handler = "exports.test"
}

Argument Reference

The following arguments are supported:

Attributes Reference

The following attributes are exported:


See the source of this document at Terraform.io

REQUEST A DEMO