Difference between revisions of "Terraform resource: aws s3 bucket cors configuration"
Jump to navigation
Jump to search
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_cors_configuration | ||
+ | == Official example == | ||
+ | resource "aws_s3_bucket" "example" { | ||
+ | bucket = "mybucket" | ||
+ | } | ||
+ | |||
+ | resource "aws_s3_bucket_cors_configuration" "example" { | ||
+ | bucket = aws_s3_bucket.example[[.id]] | ||
+ | |||
+ | cors_rule { | ||
+ | allowed_headers = ["*"] | ||
+ | allowed_methods = ["[[PUT]]", "[[POST]]"] | ||
+ | allowed_origins = ["https://s3-website-test.hashicorp.com"] | ||
+ | expose_headers = ["ETag"] | ||
+ | max_age_seconds = 3000 | ||
+ | } | ||
+ | |||
+ | cors_rule { | ||
+ | allowed_methods = ["[[GET]]"] | ||
+ | allowed_origins = ["*"] | ||
+ | } | ||
+ | } | ||
− | + | == Related == | |
* [[Terraform resource: aws_s3_bucket_website_configuration]] | * [[Terraform resource: aws_s3_bucket_website_configuration]] | ||
+ | * [[.bucket]] | ||
== See also == | == See also == | ||
* {{tf s3}} | * {{tf s3}} | ||
+ | * {{CORS}} | ||
[[Category:AWS]] | [[Category:AWS]] |
Latest revision as of 11:48, 8 March 2024
Official example[edit]
resource "aws_s3_bucket" "example" { bucket = "mybucket" } resource "aws_s3_bucket_cors_configuration" "example" { bucket = aws_s3_bucket.example.id cors_rule { allowed_headers = ["*"] allowed_methods = ["PUT", "POST"] allowed_origins = ["https://s3-website-test.hashicorp.com"] expose_headers = ["ETag"] max_age_seconds = 3000 } cors_rule { allowed_methods = ["GET"] allowed_origins = ["*"] } }
Related[edit]
See also[edit]
- Terraform S3 resources:
aws_s3_bucket, aws_s3_object, aws_s3_bucket_policy, aws_s3_bucket_acl, aws_s3_bucket_website_configuration, aws_s3_bucket cors_configuration, aws_s3_account_public_access_block
, Terraform module: s3-bucket,aws_s3_bucket_versioning, aws_s3_bucket_server_side_encryption_configuration
- CORS, HSTS,
Access-Control-Allow-Origin
, Enabling CORS for a REST API resource, Lighthouse bn --http --http-allow-origin,Caddyfile, gsutil cors, cors_rule, aws_s3_bucket_cors_configuration
Advertising: