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.
- The
gcloud
CLI tool - installation instructions. - The Terraform tool - installation guide.
- Below command authorizes access and performs other common setup steps:
gcloud init
- To ONLY authorize yourself use the following command:
gcloud auth login
- To obtain user access credentials to use for Application Default Credentials (ADC) - necessary for Terraform & SDK, run:
gcloud auth application-default login
- First, change the folder to
terraform_files
:
cd terraform_files/
- Run following command in order to initialize Terraform working directory:
terraform init
- To see Terraform execution plan run:
terraform plan
- To apply changes on GCP run:
terraform apply
⚠️ Note: After runningterraform plan
&terraform apply
you will be prompted to enter the GCP project id in which the resources are to be deployed.
- 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>