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

Cloud to Code Global Flags

You can apply global flags with the cloud2code import command to customise resource imports into an appStack, including logging, filtering, and the output settings.

Usage

cloud2code import <provider> [options] [global flags]

Available Flags

FlagDescriptionRequired
--log-level or -lSets the logging level (debug, info, warn, error, panic, fatal).No
--log-typeSets the logging output format (console, json).No
--tagsFilters resources by specified tags.No
--includeIncludes only the specified resource types.No
--excludeExcludes specific resource types from import.No
--output-dir
or -o
Specifies the output directory for Terraform state files (default: current directory).No
--auto-importAutomatically imports resources to StackGen (default based on StackgenToken).No
--appstack-idSpecifies the appStack ID for resource management.No
--download-iacDownloads Infrastructure as Code (IaC) files (default based on StackgenToken).No
--skip-default-policiesSkip assigning default resource security policies to the appstackNo

Examples

Usage

cloud2code import aws --region us-east-1 --include aws_s3_bucket,aws_instance --log-level debug --output-dir ./terraform

The above command will:

  1. Import S3 buckets and EC2 instances from AWS (us-east-1).
  2. Log details at debug level.
  3. Save the Terraform files in the ./terraform directory.

Usage

cloud2code import azure --subscription-id <subscription_id> --resource-group my-rg --exclude azure_vm --auto-import

The above command will:

  1. Import all resources from an Azure Resource Group, except VMs.
  2. Automatically import resources to StackGen if a STACKGEN_URL and STACKGEN_TOKEN environment variables are present.
  3. If STACKGEN_TEAM is present, it will import into a team appstack
  4. Since no --appstack-id is specified, it will create a new appstack.

Usage

cloud2code import gcp --project-id <project-id> --region us-central1 --credentials <creds> --appstack-id <appstackuuid> --include google_storage_bucket --auto-import

The above command will:

  1. Import all the google storage bucket resources present in us-central1 region into the appstack mentioned.
  2. It will look for following environment variables to connect to stackgen server
  3. If STACKGEN_TEAM is not set then it will look for the appstackuuid in your personal workspace.