Resource
dcloud_bucket_policy
A bucket's resource policy, in AWS's grammar. A policy that makes the bucket public is refused while block_public_policy is on (see dcloud_bucket_public_access_block).
Example Usage
# Public read of every object: needs block_public_policy = false.
resource "dcloud_bucket_public_access_block" "site" {
bucket = dcloud_bucket.site.id
block_public_acls = true
ignore_public_acls = true
block_public_policy = false
restrict_public_buckets = false
}
resource "dcloud_bucket_policy" "site" {
bucket = dcloud_bucket.site.id
policy = jsonencode({
Version = "2012-10-17"
Statement = [{
Sid = "PublicRead"
Effect = "Allow"
Principal = "*"
Action = "s3:GetObject"
Resource = "arn:aws:s3:::${dcloud_bucket.site.id}/*"
}]
})
depends_on = [dcloud_bucket_public_access_block.site]
}Schema
Required
bucket(String) The id of the parent resource ({name}in the path). Changing it replaces the resource.policy(String) The policy document (JSON); usejsonencode.
Read-Only
id(String) The resource's id.
Import
Import is supported using the following syntax:
The terraform import command can be used, for example:
terraform import dcloud_bucket_policy.site <bucket-name>Generated from the provider's schema.
Related