Azure / aztfexport

A tool to bring existing Azure resources under Terraform's management
https://azure.github.io/aztfexport/
Mozilla Public License 2.0
1.63k stars 190 forks source link

how auto skip some resource #477

Closed novohool closed 11 months ago

novohool commented 1 year ago

The resource azurerm_container_registry_scope_map has unexpect name "_xxx"

magodo commented 1 year ago

@novohool Could you please elaborate more about your issue here?

In order to skip resources, there is no mechanism to automatically do that, instead, you can either skip them in interactive mode by select them and press del, or you can generate the resource mapping file and edit the file, then feed it back to the aztfexport map subcommand.

novohool commented 1 year ago

@novohool Could you please elaborate more about your issue here? 您能在这里详细说明您的问题吗?

In order to skip resources, there is no mechanism to automatically do that, instead, you can either skip them in interactive mode by select them and press del, or you can generate the resource mapping file and edit the file, then feed it back to the aztfexport map subcommand.为了跳过资源,没有自动执行此操作的机制,您可以通过选择资源并按 del 以交互模式跳过它们,也可以生成资源映射文件并编辑该文件,然后将其反馈给 aztfexport map 子命令。 As shell to use


aztfexport config set telemetry_enabled false

az login --service-principal -t $ARM_TENANT_ID -u $ARM_CLIENT_ID -p $ARM_CLIENT_SECRET >/dev/null 2>&1 mkdir -p json az account list --query "[].{id:id, name:name}" --output json | jq -c '.[]'|grep -v test | while read account; do id=$(echo $account | jq -r '.id') name=$(echo $account | jq -r '.name') export ARM_SUBSCRIPTION_ID="$id" az account set --subscription $ARM_SUBSCRIPTION_ID az group list --subscription $ARM_SUBSCRIPTION_ID --query "[].{rgid:id, rgname:name}" --output json | jq -c '.[]'|egrep -v "test|cloud-shell|DefaultResourceGroup" | while read rg; do mkdir -p ${name} json/${name} rgid=$(echo $rg | jq -r '.rgid') rgname=$(echo $rg | jq -r '.rgname') aztfexport resource-group -f --plain-ui=true --output-dir ${name}/${rgname} --non-interactive --hcl-only ${rgname} (cd ${name}/${rgname} && jq 'with_entries(select(.key | contains("/subscriptions") and contains("Microsoft.ContainerRegistry"))) | keys | unique' aztfexportResourceMapping.json|jq .[]| while read line; do echo "- $line" >> aztfexportSkippedResources.txt; done) sed -i -e '/resource "azurerm_container_registry_scope_map"/,/}/d' ${name}/${rgname}/main.tf sed -i '/admin_password/s/ignored-as-imported/Ignored_AS@Imported888/g' ${name}/${rgname}/main.tf (cd ${name}/${rgname} && terraform init --upgrade && terraform plan -out ${rgname}.out && terraform show -json ${rgname}.out > ../../json/${name}/${rgname}.json) done done az logout

stemaMSFT commented 11 months ago

Without more details, we won't be able to resolve this issue, unfortunately @novohool.