Skip to content

Commit b50757d

Browse files
authored
Merge pull request #183847 from KimForss/master
Script update
2 parents 9f72c36 + b67760c commit b50757d

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

articles/virtual-machines/workloads/sap/bash/automation-advanced_state_management.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,41 @@ advanced_state_management.sh [--parameterfile] <String>
3131
```
3232

3333
## Description
34-
You can use this cmdlet to add missing or modified resources to the Terraform state file.
34+
You can use this script to add missing or modified resources to the Terraform state file. This script is useful if resources have been modified or created without using Terraform.
3535

3636
## Examples
3737

3838
### Example 1
3939

40+
Importing a Virtual Machine
41+
4042
```bash
4143

42-
advanced_state_management.sh --parameterfile DEV-WEEU-SAP01-X00.tfvars --type sap_system
43-
--subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
44-
--storage_account_name devweeutfstateABC
45-
--terraform_keyfile DEV-WEEU-SAP01-X00.terraform.tfstate
46-
--tf_resource_name module.sap_system.azurerm_resource_group.deployer[0]
47-
--azure_resource_id /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/DEV-WEEU-SAP01-X00
48-
```
44+
parameter_file_name="DEV-WEEU-SAP01-X00.tfvars"
45+
deployment_type="sap_system"
46+
subscriptionID="<subscriptionId>"
47+
48+
filepart=$(echo "${parameter_file_name}" | cut -d. -f1)
49+
key_file=${filepart}.terraform.tfstate
50+
51+
#This is the name of the storage account containing the terraform state files
52+
storage_accountname="<storageaccountname>"
53+
54+
#Terraform Resource name of the first
55+
tf_resource_name="module.hdb_node.azurerm_linux_virtual_machine.vm_dbnode[0]"
56+
57+
#Azure Resource id of the Virtual
58+
azure_resource_id="/subscriptions/<subscriptionId>/resourceGroups/DEV-WEEU-SAP01-X00/providers/Microsoft.Compute/virtualMachines/xxxxx"
59+
60+
$DEPLOYMENT_REPO_PATH/deploy/scripts/advanced_state_management.sh \
61+
--parameterfile "${parameter_file_name}" \
62+
--type "${deployment_type}" \
63+
--subscription "${subscriptionID}" \
64+
--storage_account_name "${storage_accountname}" \
65+
--terraform_keyfile "${key_file}" \
66+
--tf_resource_name "${tf_resource_name}" \
67+
--azure_resource_id "${azure_resource_id}"
68+
```
4969

5070
## Parameters
5171

0 commit comments

Comments
 (0)