Skip to content

The Terraform & Python code that helps to deploy static-website hosted on GCP Cloud Storage bucket. Every time an object is uploaded to static-website bucket, its Cache-Control metadata is updated by Cloud Function.

License

Notifications You must be signed in to change notification settings

luk-kop/gcp-static-website

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gcp-static-website

Terraform Python 3.10 MIT license

The code helps to deploy static-website hosted on GCP Cloud Storage bucket. Every time an object is uploaded to static-website bucket, its Cache-Control metadata is updated by Cloud Function.

Prerequisites

Required tools

  1. The gcloud CLI tool - installation instructions.
  2. The Terraform tool - installation guide.

Authorize to GCP with a user account

  1. Below command authorizes access and performs other common setup steps:
gcloud init
  1. To ONLY authorize yourself use the following command:
gcloud auth login
  1. To obtain user access credentials to use for Application Default Credentials (ADC) - necessary for Terraform & SDK, run:
gcloud auth application-default login

Deploy static website resources

  1. First, change the folder to terraform_files:
cd terraform_files/
  1. Run following command in order to initialize Terraform working directory:
terraform init
  1. To see Terraform execution plan run:
terraform plan
  1. To apply changes on GCP run:
terraform apply

⚠️ Note: After running terraform plan & terraform apply you will be prompted to enter the GCP project id in which the resources are to be deployed.

  1. Once the resources are deployed, upload website content files with following command (should be run from repository root):
gsutil rsync -R static-website-content gs://<static_website_bucket_name>

About

The Terraform & Python code that helps to deploy static-website hosted on GCP Cloud Storage bucket. Every time an object is uploaded to static-website bucket, its Cache-Control metadata is updated by Cloud Function.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published