Skip to content

Commit 61abbae

Browse files
prepared storage_static_website for inclusion on C.G.C (#6287) (#4596)
Signed-off-by: Modular Magician <[email protected]> Signed-off-by: Modular Magician <[email protected]>
1 parent 0d3cae8 commit 61abbae

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

.changelog/6287.txt

Whitespace-only changes.

google-beta/resource_cgc_snippet_generated_test.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,3 +1301,65 @@ resource "google_pubsub_topic" "topic" {
13011301
}
13021302
`, context)
13031303
}
1304+
1305+
func TestAccCGCSnippet_storageStaticWebsiteExample(t *testing.T) {
1306+
t.Parallel()
1307+
1308+
context := map[string]interface{}{
1309+
"random_suffix": randString(t, 10),
1310+
}
1311+
1312+
vcrTest(t, resource.TestCase{
1313+
PreCheck: func() { testAccPreCheck(t) },
1314+
Providers: testAccProviders,
1315+
Steps: []resource.TestStep{
1316+
{
1317+
Config: testAccCGCSnippet_storageStaticWebsiteExample(context),
1318+
},
1319+
{
1320+
ResourceName: "google_storage_bucket.static_website",
1321+
ImportState: true,
1322+
ImportStateVerify: true,
1323+
},
1324+
},
1325+
})
1326+
}
1327+
1328+
func testAccCGCSnippet_storageStaticWebsiteExample(context map[string]interface{}) string {
1329+
return Nprintf(`
1330+
# Create new storage bucket in the US multi-region
1331+
# with coldline storage and settings for main_page_suffix and not_found_page
1332+
resource "google_storage_bucket" "static_website" {
1333+
name = "tf-test-static-website-bucket%{random_suffix}"
1334+
location = "US"
1335+
storage_class = "COLDLINE"
1336+
website {
1337+
main_page_suffix = "index.html%{random_suffix}"
1338+
not_found_page = "index.html%{random_suffix}"
1339+
}
1340+
}
1341+
1342+
# Make bucket public by granting allUsers READER access
1343+
resource "google_storage_bucket_access_control" "public_rule" {
1344+
bucket = google_storage_bucket.static_website.id
1345+
role = "READER"
1346+
entity = "allUsers"
1347+
}
1348+
1349+
# Upload a simple index.html page to the bucket
1350+
resource "google_storage_bucket_object" "indexpage" {
1351+
name = "index.html%{random_suffix}"
1352+
content = "<html><body>Hello World!</body></html>"
1353+
content_type = "text/html"
1354+
bucket = google_storage_bucket.static_website.id
1355+
}
1356+
1357+
# Upload a simple 404 / error page to the bucket
1358+
resource "google_storage_bucket_object" "errorpage" {
1359+
name = "404.html%{random_suffix}"
1360+
content = "<html><body>404!</body></html>"
1361+
content_type = "text/html"
1362+
bucket = google_storage_bucket.static_website.id
1363+
}
1364+
`, context)
1365+
}

0 commit comments

Comments
 (0)