Skip to content

Commit f529f61

Browse files
mazgiglasnt
andauthored
Update main.tf: set uniform_bucket_level_access to true (#718)
Co-authored-by: Katie McLaughlin <[email protected]>
1 parent 2435e01 commit f529f61

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

storage/static_website/main.tf

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ resource "random_id" "bucket_prefix" {
2323
}
2424

2525
resource "google_storage_bucket" "static_website" {
26-
name = "${random_id.bucket_prefix.hex}-static-website-bucket"
27-
location = "US"
28-
storage_class = "STANDARD"
26+
name = "${random_id.bucket_prefix.hex}-static-website-bucket"
27+
location = "US"
28+
storage_class = "STANDARD"
29+
uniform_bucket_level_access = true
2930
website {
3031
main_page_suffix = "index.html"
3132
not_found_page = "404.html"
@@ -34,11 +35,11 @@ resource "google_storage_bucket" "static_website" {
3435
# [END storage_static_website_create_bucket_tf]
3536

3637
# [START storage_static_website_make_bucket_public_tf]
37-
# Make bucket public by granting allUsers READER access
38-
resource "google_storage_bucket_access_control" "public_rule" {
39-
bucket = google_storage_bucket.static_website.id
40-
role = "READER"
41-
entity = "allUsers"
38+
# Make bucket public by granting allUsers storage.objectViewer access
39+
resource "google_storage_bucket_iam_member" "public_rule" {
40+
bucket = google_storage_bucket.static_website.name
41+
role = "roles/storage.objectViewer"
42+
member = "allUsers"
4243
}
4344
# [END storage_static_website_make_bucket_public_tf]
4445

0 commit comments

Comments
 (0)