91aad8a23bf94abe9b7bd57bef764520 by 2024
Author:2024
Language: eng
Format: epub
Chapter 4 provisioning infrastruCture on gCp Google Cloud Console: You can manually check the
details of the bucket. Navigate to the Storage section,
find the bucket named ivys_bucket_a, and review
its configuration to confirm that it matches what was
defined in your Terraform files.
Command Line: Using the Google Cloud gcloud
command-line tool is often a quicker and more
automated way to verify the creation of resources.
To check the details of the bucket, run the following
command:
$ gcloud storage buckets describe gs://ivys_bucket_a
This command retrieves and displays the details
of the bucket named ivys_bucket_a. By reviewing
this information, you can confirm that the bucket
matches the configuration specified in your
Terraform files and that everything was set up
according to your expectations.
Create Multiple Storage Buckets
In this section, you will explore how to use variables and functions to create and manage multiple resources simultaneously, ensuring consistency and saving time.
In this example, you will create three storage buckets in the same region with different names.
provider "google" {
project = "terraform-made-easy"
region = "us-central1"
# credentials = file("path/to/your/service-account-key.json")
}
101
Chapter 4 provisioning infrastruCture on gCp
# Variables
variable "bucket_names" {
type = list(string)
description = "A list of names for the Google Cloud Storage buckets to be created."
default = ["ivys_bucket_1", "ivys_bucket_2",
"ivys_bucket_3"]
}
variable "location" {
type = string
description = "The geographic location where the storage buckets will be created."
default = "us-central1"
}
variable "storage_class" {
type = string
description = "The storage class to be assigned to the
buckets (e.g., STANDARD, NEARLINE)."
default = "STANDARD"
}
# Resource Definition
resource "google_storage_bucket" "buckets" {
count = length(var.bucket_names)
name = var.bucket_names[count.index]
location = var.location
storage_class = var.storage_class
}
102
Chapter 4 provisioning infrastruCture on gCp The first block in the configuration is the provider block. In this block, youâll notice a line for credentials that has been commented out. This is because, in this scenario, youâre using the Google Cloud environment directly, which handles authentication automatically.
However, if youâre not using Google Cloud SDK authentication or working directly within a Google Cloud environment, youâll need to specify the credentials explicitly. This credentials line points to a service account key file, which provides Terraform with the necessary authentication to manage Google Cloud resources. For more details on how to set up and use credentials with Terraform on Google Cloud, you can refer to the documentation on authentication.
Following the provider block, you have three variable blocks that define key configuration settings The variable bucket_names defines a variable called bucket_names, which is a list of strings. The description explains that this variable will hold the names of the storage buckets to be created, making it clear and reader-friendly.The default value is a list containing bucket1, bucket2, and bucket3.
The last block is the resource block. Here, the count meta-argument is set to the length of the bucket_names list, which means that this resource block will be instantiated once for each bucket name provided. The name argument within the block dynamically sets the name of each bucket, using count.index to reference the corresponding element in the bucket_
names list. This ensures that each bucket is uniquely named according to the values specified in the bucket_names variable. Later in this chapter, you will explore how to achieve similar results using the for_each meta-argument, which offers additional flexibility and control.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
What's Done in Darkness by Kayla Perrin(26282)
Shot Through the Heart: DI Grace Fisher 2 by Isabelle Grey(18807)
Shot Through the Heart by Mercy Celeste(18693)
The Fifty Shades Trilogy & Grey by E L James(18587)
The Subtle Art of Not Giving a F*ck by Mark Manson(13907)
The 3rd Cycle of the Betrayed Series Collection: Extremely Controversial Historical Thrillers (Betrayed Series Boxed set) by McCray Carolyn(13847)
Stepbrother Stories 2 - 21 Taboo Story Collection (Brother Sister Stepbrother Stepsister Taboo Pseudo Incest Family Virgin Creampie Pregnant Forced Pregnancy Breeding) by Roxi Harding(12784)
Scorched Earth by Nick Kyme(12513)
Drei Generationen auf dem Jakobsweg by Stein Pia(10741)
Suna by Ziefle Pia(10674)
Scythe by Neal Shusterman(10027)
International Relations from the Global South; Worlds of Difference; First Edition by Arlene B. Tickner & Karen Smith(9286)
Successful Proposal Strategies for Small Businesses: Using Knowledge Management ot Win Govenment, Private Sector, and International Contracts 3rd Edition by Robert Frey(9099)
This is Going to Hurt by Adam Kay(8733)
Dirty Filthy Fix: A Fixed Trilogy Novella by Laurelin Paige(7350)
How to Make Love to a Negro Without Getting Tired by Dany LaFerrière(6756)
He Loves Me...KNOT by RC Boldt(6638)
Unleashing the Power of UX Analytics: Proven techniques and strategies for uncovering user insights [Team-IRA] [True PDF] by Jeff Hendrickson(6335)
Interdimensional Brothel by F4U(6091)
