Create a Cloud Storage Bucket

Create a Cloud Storage Bucket with main page and not found page settings.

Code sample

Terraform

To learn how to apply or remove a Terraform configuration, see Basic Terraform commands . For more information, see the Terraform provider reference documentation .

  # Create new storage bucket in the US multi-region 
 # and settings for main_page_suffix and not_found_page 
 resource 
  
 "random_id" 
  
 "bucket_prefix" 
  
 { 
  
 byte_length 
  
 = 
  
 8 
 } 
 resource 
  
 "google_storage_bucket" 
  
 "static_website" 
  
 { 
  
 name 
  
 = 
  
 "${random_id.bucket_prefix.hex}-static-website-bucket" 
  
 location 
  
 = 
  
 "US" 
  
 storage_class 
  
 = 
  
 "STANDARD" 
  
 uniform_bucket_level_access 
  
 = 
  
 true 
  
 website 
  
 { 
  
 main_page_suffix 
  
 = 
  
 "index.html" 
  
 not_found_page 
  
 = 
  
 "404.html" 
  
 } 
 } 
 

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser .

Design a Mobile Site
View Site in Mobile | Classic
Share by: