Generating templates from existing resources with IaC generator
With the CloudFormation IaC generator (infrastructure as code generator), you can generate a template using AWS resources provisioned in your account that are not already managed by CloudFormation.
The following are benefits of the IaC generator:
-
Bring entire applications under CloudFormation management or migrate them into an AWS CDK app.
-
Generate templates without having to describe a resource property by property and then translate that into JSON or YAML syntax.
-
Use the template to replicate resources in a new account or Region.
The IaC generation process consists of the following steps:
-
Scan resources – The first step is to start a scan of your resources. This scan is region-wide and lasts for 30 days. During this time, you can create multiple templates from the same scan.
-
Create your template – To create the template, you have two options:
-
Create a new template from scratch and add the scanned resources and related resources to it.
-
Use an existing CloudFormation stack as a starting point and add the scanned resources and related resources to its template.
-
-
Import resources – Use your template to import the resources as a CloudFormation stack or migrate them into an AWS CDK app.
The IaC generator feature is available in all commercial Regions and supports many common AWS resource types. For a full list, see Resource type support.
Topics
Considerations
You can generate JSON or YAML templates for AWS resources published to the CloudFormation registry, for resources for which you have Read permissions. The templates for the IaC generator capability models cloud resources reliably and quickly without having to describe a resource property by property.
The following table lists the quotas available for the IaC generation feature.
Name | Value |
---|---|
Maximum number of resources that can be processed in an account scan |
100000 |
Number of scans per day (for accounts with less than 10,000 resources) |
3 |
Number of scans per day (for accounts with more than 10,000 resources) |
1 |
Concurrent number of templates generating per account |
5 |
Concurrent number of resources modeled for one template generation. |
5 |
Total number of resources that can be modeled in one template |
500 |
Maximum number of generated templates per account |
1,000 |
Important
IaC generator only supports resources that are supported by Cloud Control API in your Region. For more information, see Determining if a resource type supports Cloud Control API in the Cloud Control API User Guide
Commonly used commands for template generation, management, and deletion
The commonly used commands for working with IaC generator include:
-
start-resource-scan to start a scan of the resources in the account in an AWS Region.
-
describe-resource-scan to monitor the progress of a resource scan.
-
list-resource-scans to list the resource scans in an AWS Region.
-
list-resource-scan-resources to list the resources found during the resource scan.
-
list-resource-scan-related-resources to list the resources related to your scanned resources.
-
create-generated-template to generate a CloudFormation template from a set of scanned resources.
-
update-generated-template to update the generated template.
-
describe-generated-template to return information about a generated template.
-
list-generated-templates to list all generated templates in your account and current Region.
-
delete-generated-template to delete a generated template.
Migrate a template to the AWS CDK
The AWS Cloud Development Kit (AWS CDK) is an open-source software development framework that you can use to develop, manage, and deploy CloudFormation resources using popular programming languages.
The AWS CDK CLI provides an integration with IaC generator. Use the AWS CDK CLI cdk
migrate
command to convert the CloudFormation template and create a new CDK app
that contains your resources. Then, you can use the AWS CDK to manage your resources and
deploy to CloudFormation.
For more information, see Migrate to AWS CDK in the AWS Cloud Development Kit (AWS CDK) Developer Guide.