Bring Your Cloud Resources Into Management Through Iac
Overview
Managing cloud dependencies and provisioning infrastructure efficiently is critical for most DevOps and Engineering teams. With the Cloud to Code CLI feature, you can:
-
Gain clear visibility into your cloud environment through our topology page, allowing you to identify resource dependencies effortlessly.
-
Generate modernized Infrastructure as Code (IaC) templates for your cloud resources. No prior IaC setup is required, saving you valuable time and effort.
-
Retrieve a comprehensive list of all deployed resources in your cloud with a simple query.
-
Use your generated state file to create an appStack in StackGen. To learn more, refer to the IaC from State Files guide.
Clouds Supported: AWS and Azure.
noteYou’ll need to contact StackGen Support to use this CLI tool.
Key Features
- Dependency Management – Automatically detect managed and unmanaged resources and resolve dependencies within various resources.
- Bulk Operations – Scan and generate IaC for your resources in bulk.
Use Cases
Your teams can now accelerate their cloud migration and enforce best practices for Infrastructure-as-Code (IaC) by seamlessly onboarding your cloud resources.
As a DevOps engineer, you can:
- Automate large-scale infrastructure provisioning and maintain consistency across environments.
- Enhance developer workflows by automating environment setup and managing dependencies efficiently.
We’ve listed some of the ways you can leverage this feature.
Import Specific AWS S3 Buckets by Name
This feature allows you to import specific S3 buckets into the IaC setup so that the buckets you’ve specified are automatically imported into your tfstate
file, eliminating the need to configure your resources manually.
Run the following command to view the list of all S3 buckets in your cloud:
aws s3 ls
Now, run the command below after you’ve replaced the bucket names with the ones you'd like to import from your cloud:
cloud2code import aws --region us-east-1 --ids bucket_name_1,bucket_name_2 --resource-type aws_s3_bucket --output-dir /Users/abc/Downloads/terraform
Bulk Import Resources Using Tags
Import all AWS cloud resources with a Production tag from the DevOps team, thus ensuring consistency in infrastructure management.
cloud2code import aws --region us-east-1 --tags Environment:Production,Team:DevOps --output-dir /Users/abc/Downloads/terraform
Import Only Specific Resource Types Using Tags
Fetch S3 buckets and EC2 instances tagged as Production. This allows you to import only the required resource types and prevent the import of irrelevant configurations.
cloud2code import aws --region us-east-1 --tags Environment:Production --include aws_s3_bucket,aws_instance --output-dir /Users/abc/Downloads/terraform
Import All Resources Within a Region
Import all resources within a region, generate a StackGen Topology view, and download the updated IaC files.
cloud2code import aws --region us-east-1 --appstack-id="$APPSTACK_ID" --auto-import=true --download-iac=true --output-dir “/Users/abc/Downloads/terraform”
Using the same Cloud to Code CLI, your developers can also perform the following actions.
Exclude Resource Types from Import
Import all resources tagged as Production, excluding IAM roles, Route53 records, and IAM policies, so you do not override any security-related IAM configurations while importing your infrastructure.
cloud2code import aws --region us-east-1 --tags Environment:Production --exclude aws_iam_role,aws_iam_policy,aws_route53_record,aws_iam_role_policy,aws_iam_role_policy_attachment --output-dir “/Users/abc/Downloads/terraform”
Import Specific Resource Types With Multiple Tags
Fetch all S3 buckets and EC2 instances from the us-east-1
region with Environment:Production
and CreatedBy:user1
tags to selectively retrieve the required resources for optimised infrastructure provisioning.
cloud2code import aws --region us-east-1 --tags "Environment:Production,CreatedBy:user1" --include aws_s3_bucket,aws_instance --output-dir “/Users/abc/Downloads/terraform”