Open2
Azure x Terraform

リソースグループ作成
version
terraform version
-
結果例
r_ota [ ~/clouddrive ]$ terraform version Terraform v1.3.2 on linux_amd64 + provider registry.terraform.io/hashicorp/azurerm v3.78.0 Your version of Terraform is out of date! The latest version is 1.6.2. You can update by downloading from https://www.terraform.io/downloads.html r_ota [ ~/clouddrive ]$
tf ファイル
main.tf
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "r_ota" {
name = "r_ota2"
location = "japaneast"
}
デプロイ(?)
terraform init
terraform plan
terraform apply

workspace
参考
検証
terraform workspace list
#terraform workspace new 【名前】
terraform workspace new test
terraform workspace list
terraform workspace show
#terraform workspace select 【名前】
terraform workspace select default
-
結果例
r_ota [ ~/clouddrive/terraform ]$ terraform workspace list * default r_ota [ ~/clouddrive/terraform ]$ terraform workspace new test Created and switched to workspace "test"! You're now on a new, empty workspace. Workspaces isolate their state, so if you run "terraform plan" Terraform will not see any existing state for this configuration. r_ota [ ~/clouddrive/terraform ]$ ls terraform.tfstate.d/ test r_ota [ ~/clouddrive/terraform ]$ terraform workspace list default * test r_ota [ ~/clouddrive/terraform ]$ terraform workspace show test r_ota [ ~/clouddrive/terraform ]$ terraform workspace select default Switched to workspace "default". r_ota [ ~/clouddrive/terraform ]$ terraform workspace list * default test r_ota [ ~/clouddrive/terraform ]$
メモ
何に使うんだろうか??
- ソースはGit管理(環境、tf実行単位で分ける)
- ソースはGit管理(環境はごちゃまぜ)だが、切り替えはTerraformのWorkspaceで切り替える
って使いわけでもするのか・・?