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
| Flag | Description | Required |
|---|---|---|
--log-level or -l | Sets the logging level (debug, info, warn, error, panic, fatal). | No |
--log-type | Sets the logging output format (console, json). | No |
--tags | Filters resources by specified tags. | No |
--include | Includes only the specified resource types. | No |
--exclude | Excludes specific resource types from import. | No |
--output-dir or -o | Specifies the output directory for Terraform state files (default: current directory). | No |
--auto-import | Automatically imports resources to StackGen (default based on StackgenToken). | No |
--appstack-id | Specifies the appStack ID for resource management. | No |
--download-iac | Downloads Infrastructure as Code (IaC) files (default based on StackgenToken). | No |
--skip-default-policies | Skip assigning default resource security policies to the appstack | No |
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:
- Import S3 buckets and EC2 instances from AWS (
us-east-1). - Log details at debug level.
- Save the Terraform files in the
./terraformdirectory.
Usage
cloud2code import azure --subscription-id <subscription_id> --resource-group my-rg --exclude azure_vm --auto-import
The above command will:
- Import all resources from an Azure Resource Group, except VMs.
- Automatically import resources to StackGen if a
STACKGEN_URLandSTACKGEN_TOKENenvironment variables are present. - If
STACKGEN_TEAMis present, it will import into a team appstack - Since no
--appstack-idis 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:
- Import all the google storage bucket resources present in us-central1 region into the appstack mentioned.
- It will look for following environment variables to connect to stackgen server
- STACKGEN_URL (url of the stackgen server https://customer.cloud.stackgen.com)
- STACKGEN_TOKEN (stackgen_******)
- STACKGEN_TEAM (UUID, also known as project ID)
- If STACKGEN_TEAM is not set then it will look for the appstackuuid in your personal workspace.