$npx -y skills add pulumi/agent-skills --skill pulumi-arm-to-pulumiConvert or migrate Azure ARM (Azure Resource Manager) templates, Bicep templates, or code to Pulumi, including importing existing Azure resources. This skill MUST be loaded whenever a user requests migration, conversion, or import of ARM templates, Bicep templates, ARM code, Bice
| 1 | ## IMPORTANT: PLAN ADJUSTMENT REQUIRED |
| 2 | |
| 3 | **If you have already generated a migration plan before loading this skill, you MUST:** |
| 4 | |
| 5 | 1. Review your existing plan against the workflows and requirements in this skill |
| 6 | 2. Identify any gaps, missing steps, or incorrect assumptions |
| 7 | 3. Update and revise your plan to align with this skill's guidance |
| 8 | 4. Communicate the adjusted plan to the user before proceeding |
| 9 | |
| 10 | ## CRITICAL SUCCESS REQUIREMENTS |
| 11 | |
| 12 | The migration output MUST meet all of the following: |
| 13 | |
| 14 | 1. **Complete Resource Coverage** |
| 15 | - Every ARM template resource MUST: |
| 16 | - Be represented in the Pulumi program **OR** |
| 17 | - Be explicitly justified in the final report. |
| 18 | |
| 19 | 2. **Successful Deployment** |
| 20 | - The produced Pulumi program must be structurally valid and capable of a successful `pulumi preview` (assuming proper config). |
| 21 | |
| 22 | 3. **Zero-Diff Import Validation** (if importing existing resources) |
| 23 | - After import, `pulumi preview` must show: |
| 24 | - NO updates |
| 25 | - NO replaces |
| 26 | - NO creates |
| 27 | - NO deletes |
| 28 | - Any diffs must be resolved using the Preview Resolution Workflow. See [arm-import.md](arm-import.md). |
| 29 | |
| 30 | 4. **Final Migration Report** |
| 31 | - Always output a formal migration report suitable for a Pull Request. |
| 32 | - Include: |
| 33 | - ARM → Pulumi resource mapping |
| 34 | - Provider decisions (azure-native vs azure) |
| 35 | - Behavioral differences |
| 36 | - Missing or manually required steps |
| 37 | - Validation instructions |
| 38 | |
| 39 | ## WHEN INFORMATION IS MISSING |
| 40 | |
| 41 | If a user-provided ARM template is incomplete, ambiguous, or missing artifacts, ask **targeted questions** before generating Pulumi code. |
| 42 | |
| 43 | If there is ambiguity on how to handle a specific resource property on import, ask **targeted questions** before altering Pulumi code. |
| 44 | |
| 45 | ## MIGRATION WORKFLOW |
| 46 | |
| 47 | Follow this workflow **exactly** and in this order: |
| 48 | |
| 49 | ### 1. INFORMATION GATHERING |
| 50 | |
| 51 | #### 1.1 Verify Azure Credentials |
| 52 | |
| 53 | Running Azure CLI commands (e.g., `az resource list`, `az resource show`). Requires initial login using ESC and `az login` |
| 54 | |
| 55 | - If the user has already provided an ESC environment, use it. |
| 56 | - If no ESC environment is specified, **ask the user which ESC environment to use** before proceeding with Azure CLI commands. |
| 57 | |
| 58 | **Setting up Azure CLI using ESC:** |
| 59 | |
| 60 | - ESC environments can provide Azure credentials through environment variables or Azure CLI configuration |
| 61 | - Login to Azure using ESC to provide credentials, e.g: `pulumi env run {org}/{project}/{environment} -- bash -c 'az login --service-principal -u "$ARM_CLIENT_ID" --tenant "$ARM_TENANT_ID" --federated-token "$ARM_OIDC_TOKEN"'`. ESC is not required after establishing the session |
| 62 | - Verify credentials are working: `az account show` |
| 63 | - Confirm subscription: `az account list --query "[].{Name:name, SubscriptionId:id, IsDefault:isDefault}" -o table` |
| 64 | |
| 65 | **For detailed ESC information:** Load the `pulumi-esc` skill by calling the tool "Skill" with name = "pulumi-esc" |
| 66 | |
| 67 | #### 1.2 Analyze ARM Template Structure |
| 68 | |
| 69 | ARM templates do not have the concept of "stacks" like CloudFormation. Read the ARM template JSON file directly: |
| 70 | |
| 71 | ```bash |
| 72 | # View template structure |
| 73 | cat template.json | jq '.resources[] | {type: .type, name: .name}' |
| 74 | |
| 75 | # View parameters |
| 76 | cat template.json | jq '.parameters' |
| 77 | |
| 78 | # View variables |
| 79 | cat template.json | jq '.variables' |
| 80 | ``` |
| 81 | |
| 82 | Extract: |
| 83 | |
| 84 | - Resource types and names |
| 85 | - Parameters and their default values |
| 86 | - Variables and expressions |
| 87 | - Dependencies (dependsOn arrays) |
| 88 | - Nested templates or linked templates |
| 89 | - Copy loops (iteration constructs) |
| 90 | - Conditional deployments (condition property) |
| 91 | |
| 92 | **Documentation:** [ARM Template Structure](https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/syntax) |
| 93 | |
| 94 | #### 1.3 Build Resource Inventory (if importing existing resources) |
| 95 | |
| 96 | If the ARM template has already been deployed and you're importing existing resources: |
| 97 | |
| 98 | ```bash |
| 99 | # List all resources in a resource group |
| 100 | az resource list \ |
| 101 | --resource-group <resource-group-name> \ |
| 102 | --output json |
| 103 | |
| 104 | # Get specific resource details |
| 105 | az resource show \ |
| 106 | --ids <resource-id> \ |
| 107 | --output json |
| 108 | |
| 109 | # Query specific properties using JMESPath |
| 110 | az resource show \ |
| 111 | --ids <resource-id> \ |
| 112 | --query "{name:name, location:location, properties:properties}" \ |
| 113 | --output json |
| 114 | ``` |
| 115 | |
| 116 | **Documentation:** [Azure CLI Documentation](https://learn.microsoft.com/en-us/cli/azure/) |
| 117 | |
| 118 | ### 2. CODE CONVERSION (ARM → PULUMI) |
| 119 | |
| 120 | **IMPORTANT:** ARM to Pulumi conversion requires manual translation. There is **NO** automated conversion tool for ARM templates. You are responsible for the complete conversion. |
| 121 | |
| 122 | #### Key Conversion Principles |
| 123 | |
| 124 | 1. **Provider Strategy**: |
| 125 | - **Default**: Use `@pulumi/azure-native` for |