terraform/website/source/docs/providers/aws/r/s3_bucket.html.markdown

68 lines
2.0 KiB
Markdown
Raw Normal View History

2014-07-23 22:38:12 +02:00
---
layout: "aws"
page_title: "AWS: aws_s3_bucket"
sidebar_current: "docs-aws-resource-s3-bucket"
2014-10-22 05:21:56 +02:00
description: |-
Provides a S3 bucket resource.
2014-07-23 22:38:12 +02:00
---
# aws\_s3\_bucket
Provides a S3 bucket resource.
## Example Usage
2015-05-01 15:48:08 +02:00
### Private Bucket w/ Tags
2014-07-23 22:38:12 +02:00
```
resource "aws_s3_bucket" "b" {
bucket = "my_tf_test_bucket"
acl = "private"
2015-04-23 14:25:13 +02:00
tags {
Name = "My bucket"
Environment = "Dev"
}
2014-07-23 22:38:12 +02:00
}
```
2015-05-01 15:48:08 +02:00
### Static Website Hosting
```
resource "aws_s3_bucket" "b" {
bucket = "s3-website-test.hashicorp.com"
acl = "public-read"
policy = "#{file("policy.json")}"
2015-05-01 15:48:08 +02:00
website {
index_document = "index.html"
error_document = "error.html"
}
}
```
2014-07-23 22:38:12 +02:00
## Argument Reference
The following arguments are supported:
* `bucket` - (Required) The name of the bucket.
* `acl` - (Optional) The [canned ACL](http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl) to apply. Defaults to "private".
* `policy` - (Optional) A valid [bucket policy](http://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html) JSON document.
2015-04-23 14:25:13 +02:00
* `tags` - (Optional) A mapping of tags to assign to the bucket.
2015-05-01 15:48:08 +02:00
* `website` - (Optional) A website object (documented below).
The website object supports the following:
* `index_document` - (Required, unless using `redirect_all_requests_to`) Amazon S3 returns this index document when requests are made to the root domain or any of the subfolders.
2015-05-01 15:48:08 +02:00
* `error_document` - (Optional) An absolute path to the document to return in case of a 4XX error.
* `redirect_all_requests_to` - (Optional) A hostname to redirect all website requests for this bucket to.
2014-07-23 22:38:12 +02:00
## Attributes Reference
The following attributes are exported:
2015-05-01 15:48:08 +02:00
* `id` - The name of the bucket.
* `hosted_zone_id` - The [Route 53 Hosted Zone ID](http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_website_region_endpoints) for this bucket's region.
2015-05-07 18:09:19 +02:00
* `region` - The AWS region this bucket resides in.
2015-05-01 15:48:08 +02:00
* `website_endpoint` - The website endpoint, if the bucket is configured with a website. If not, this will be an empty string.