Skip to main content
⏳ Estimated read time: 4 min read

Discover Resources on Azure

Prerequisites

Before proceeding with Cloud to Code CLI, you’ll need to meet the requirements listed below.

  1. Install Homebrew (macOS and Linux) and Terraform.
  2. Install cloud2code on your system. Check out OS-specific installation guides.
  3. If you do not have Azure CLI installed, refer to the Azure documentation.

Authenticate Your AZ CLI

  1. Run the following command to authenticate your Azure CLI:

    az login
  2. Follow the on-screen instructions to finish authenticating.

Refer to the Azure documentation to learn more about CLI authentication.

Read Access to Resources

Ensure you have the necessary permissions to access your cloud regions and resources. If unsure, check with your cloud administrator or run the following command to verify your account details:

az account show

Create a Terraform State File

Follow these steps to create and import a tfstate file:

  1. Use the command line to create a local Terraform folder and switch your directory to the local folder.
  2. Run the command below to create a terraform state file for the resources within a resource group. You will find your tfstate file in the directory specified in Step 1.

Usage

cloud2code import azure --subscription-id <subscription_id> --resource-group <resource_group>

cloud2code Flags Explained

FlagDescriptionRequired
--subscription-idThe Azure Subscription ID from which resources will be imported.Yes
--resource-groupThe name of the Azure Resource Group to import.Yes
--output-dirOutput Terraform state file path.Yes

Example:

Run the following command to create a terraform state file for the resources in a std-test-template resource group:

cloud2code import azure --subscription-id a1b2c3d4-567e-89f0-1234-56789abcdef0 --resource-group standard-test-template --output-dir /Users/abc/Downloads