概要
Terraform状態ファイルの管理を許可します。
構文
advanced_state_management.sh [--parameterfile] <String>
[--type] <String>
[--operation] <String>
[--terraform_keyfile] <String>
[--subscription] <String>
[--storage_account_name] <String>
[--tf_resource_name] <String>
[--azure_resource_id] <String>
[--help]
説明
このスクリプトを使用すると、次のことができます:
- Terraform 状態ファイル内のリソースを一覧表示します。
- 不足しているリソースまたは変更されたリソースを Terraform 状態ファイルに追加します。
- Terraform 状態ファイルからリソースを削除します。
このスクリプトは、Terraform を使用せずにリソースを変更または作成する場合に便利です。
例
例 1
Terraform 状態ファイルの内容を一覧表示します。
parameter_file_name="DEV-WEEU-SAP01-X00.tfvars"
deployment_type="sap_system"
subscriptionID="<subscriptionId>"
filepart=$(echo "${parameter_file_name}" | cut -d. -f1)
key_file=${filepart}.terraform.tfstate
#This is the name of the storage account containing the terraform state files
storage_accountname="<storageaccountname>"
$DEPLOYMENT_REPO_PATH/deploy/scripts/advanced_state_management.sh \
--parameterfile "${parameter_file_name}" \
--type "${deployment_type}" \
--operation list \
--subscription "${subscriptionID}" \
--storage_account_name "${storage_accountname}" \
--terraform_keyfile "${key_file}"
例 2
バーチャル マシンのインポート
parameter_file_name="DEV-WEEU-SAP01-X00.tfvars"
deployment_type="sap_system"
subscriptionID="<subscriptionId>"
filepart=$(echo "${parameter_file_name}" | cut -d. -f1)
key_file=${filepart}.terraform.tfstate
#This is the name of the storage account containing the terraform state files
storage_accountname="<storageaccountname>"
#Terraform Resource name of the first
tf_resource_name="module.hdb_node.azurerm_linux_virtual_machine.vm_dbnode[0]"
#Azure Resource id of the Virtual
azure_resource_id="/subscriptions/<subscriptionId>/resourceGroups/DEV-WEEU-SAP01-X00/providers/Microsoft.Compute/virtualMachines/xxxxx"
$DEPLOYMENT_REPO_PATH/deploy/scripts/advanced_state_management.sh \
--parameterfile "${parameter_file_name}" \
--type "${deployment_type}" \
--operation import \
--subscription "${subscriptionID}" \
--storage_account_name "${storage_accountname}" \
--terraform_keyfile "${key_file}" \
--tf_resource_name "${tf_resource_name}" \
--azure_resource_id "${azure_resource_id}"
例 3
状態ファイルからのストレージ アカウントの削除
parameter_file_name="DEV-WEEU-SAP01-X00.tfvars"
deployment_type="sap_system"
subscriptionID="<subscriptionId>"
filepart=$(echo "${parameter_file_name}" | cut -d. -f1)
key_file=${filepart}.terraform.tfstate
#This is the name of the storage account containing the terraform state files
storage_accountname="<storageaccountname>"
#Terraform Resource name of the first
tf_resource_name="module.common_infrastructure.azurerm_storage_account.sapmnt[0]"
$DEPLOYMENT_REPO_PATH/deploy/scripts/advanced_state_management.sh \
--parameterfile "${parameter_file_name}" \
--type "${deployment_type}" \
--operation remove \
--subscription "${subscriptionID}" \
--storage_account_name "${storage_accountname}" \
--terraform_keyfile "${key_file}" \
--tf_resource_name "${tf_resource_name}"
パラメーター
--parameterfile
システムのパラメーター ファイルを設定します。
Type: String
Aliases: `-p`
Required: True
--type
システムの種類を設定します。 有効な値は、sap_deployer
、sap_library
、sap_landscape
、sap_system
です。
Type: String
Aliases: `-t`
Accepted values: sap_deployer, sap_landscape, sap_library, sap_system
Required: True
--operation
実行する操作を設定します。 有効な値は、sap_deployer
、import
、list
、remove
です。
Type: String
Aliases: `-t`
Accepted values: import, list, remove
Required: True
--terraform_keyfile
Terraform 状態ファイルの名前を設定します。
Type: String
Aliases: `-k`
Required: True
--subscription
ターゲット Azure サブスクリプションを設定します。
Type: String
Aliases: `-s`
Required: False
--storageaccountname
Terraform 状態ファイルを含むストレージ アカウントの名前を設定します。
Type: String
Aliases: `-a`
Required: False
--tf_resource_name
Terraform 状態ファイルのリソース名を設定します。
Type: String
Aliases: `-n`
Required: False
--azure_resource_id
インポートする Azure リソースのリソース ID を設定します。
Type: String
Aliases: `-i`
Required: False
Notes
v0.9 - 初期バージョン
Copyright (c) Microsoft Corporation. MIT ライセンスにより許諾されています。