mirror of
https://github.com/ghndrx/tf-variable-demo.git
synced 2026-02-10 06:54:57 +00:00
+ ENV $PROJEC_ID
This commit is contained in:
10
README.md
10
README.md
@@ -9,7 +9,7 @@ Using the -var flag, you can pass variables directly to the terraform apply or t
|
||||
Example:
|
||||
|
||||
|
||||
```terraform apply -var="project_id=variable-tf-demo" -var="region=us-central1" -var="zone=us-central1-f" -var="image_name=debian-cloud/debian-10" -var="instance_type=n1-standard-4"```
|
||||
```terraform apply -var="project_id=$PROJECT_ID" -var="region=us-central1" -var="zone=us-central1-f" -var="image_name=debian-cloud/debian-10" -var="instance_type=n1-standard-4"```
|
||||
|
||||
Environment variables:
|
||||
Set Terraform variables using environment variables by following the naming convention TF_VAR_variable_name. This method is useful for storing sensitive data or when using CI/CD pipelines.
|
||||
@@ -19,7 +19,7 @@ Example:
|
||||
|
||||
```
|
||||
export TF_VAR_credentials_file="credentials.json"
|
||||
export TF_VAR_project_id="variable-tf-demo"
|
||||
export TF_VAR_project_id="$PROJECT_ID"
|
||||
export TF_VAR_region="us-central1"
|
||||
export TF_VAR_zone="us-central1-a"
|
||||
export TF_VAR_image_name="debian-cloud/debian-11"
|
||||
@@ -34,7 +34,7 @@ Example (terraform.tfvars.json):
|
||||
```
|
||||
{
|
||||
"credentials_file": "credentials.json",
|
||||
"project_id": "variable-tf-demo",
|
||||
"project_id": "$PROJECT_ID",
|
||||
"region": "us-central1",
|
||||
"zone": "us-central1-a",
|
||||
"image_name": "debian-cloud/debian-11",
|
||||
@@ -46,7 +46,7 @@ Example (terraform.tfvars):
|
||||
|
||||
```
|
||||
credentials_file = "credentials.json"
|
||||
project_id = "variable-tf-demo"
|
||||
project_id = "$PROJECT_ID"
|
||||
region = "us-central1"
|
||||
zone = "us-central1-a"
|
||||
image_name = "debian-cloud/debian-11"
|
||||
@@ -59,7 +59,7 @@ Example (variables.tf):
|
||||
|
||||
```
|
||||
variable "project_id" {
|
||||
default = "variable-tf-demo"
|
||||
default = "$PROJECT_ID"
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
|
||||
Reference in New Issue
Block a user