Skip to content

jorgel272/cloudstorage-terraform-state-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloudstorage-terraform-state-backend

This Terraform plan will help you to create a Google Cloud Storage bucket and use it as backend file to store your Terraform state file. There is also a backend.tf.sample file to configure the remote backend.

Steps for running Terraform plan

  1. Create a service account with sufficient permissions.
  2. Please make sure that have the required Cloud Storage permissions for your account:
  • storage.buckets.create
  • storage.buckets.list
  • storage.objects.get
  • storage.objects.create
  • storage.objects.delete
  • storage.objects.update
  1. Download the JSON key file of the service account to your local computer.
  2. Adjust the path " "path/to/your/service-account-key.json"" of the JSON key file in the variable "gcp_service_credentials".
  3. Set the name of your Google Cloud project in the variable "gcp_project_id.
  4. Run the main.tf script terraform apply to create a Cloud Storage bucket with the correct settings.
  5. Rename the backend.tf.sample to backend.tf and store it in the root of your Terraform repository.
  6. Edit the backend.tf and add the name of the create Cloud Storage bucket.
  7. Run terraform init to configure the Terraform backend.
  8. Use the command terraform show to see if the backend is configured correctly, you should now see the output of the most recent state file.

If you already have a local state file, Terraform will detect it and prompt you to copy it to the create Cloud Storage bucket.

VAMOS, happy coding! 😃

About

Create Cloud Storage bucket and use it as Terraform statefile backend.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages