Based on our Infrastructure as Code (IaC) experience at Binbash (https://www.binbash.com.ar) we found several ways to translate existing manually deployed (from Web Console UI) AWS infra to Cloudformation (CF) and / or Terraform (TF) code.
AWS Cloudformation Templates
CF-#1 | AWS CloudFormation native import feature
Introduced feature (since Nov 2019) that allows to Import existing resources into a CloudFormation stack
For more info check: https://aws.amazon.com/blogs/aws/new-import-existing-resources-into-a-cloudformation-stack/
CF-#2 | aws cli
& manually translate to CF
Execute $aws service_name_here describe
for each element that make up your stack, eg for RDS Database Stack:
- RDS Instance ->
Type: AWS::RDS::DBInstance
, - RDS (EC2) SG ->
Type: AWS::EC2::SecurityGroup
, - RDS Subnet Group ->
Type: AWS::RDS::DBSubnetGroup
and - RDS DB Param Group ->
Type: AWS::RDS::DBParameterGroup
Afterwards manually translate to CF based on the outputs obtained from the aws cli
for each of the components. This approach usually requires more experience in both AWS and CF, but the templates that you are creating can be structured and designed under best practices, fully parameterized (Sub, Ref, Join, Fn::GetAtt:, Fn::ImportValue
), modular, applying conditions
. As a result your 1st iteration would probably be close to the final state of the templates
Very interesting reference examples: https://github.com/widdix/aws-cf-templates/
CF-#3 | Former2
Former2 allows you to generate Infrastructure-as-Code outputs from your existing resources within your AWS account. By making the relevant calls using the AWS JavaScript SDK, Former2 will scan across your infrastructure and present you with the list of resources for you to choose which to generate outputs for.
Terraform Code / Modules
TF-#1 | CloudCraft + Modules.tf
Map your reality, don't waste time producing static documentation that is outdated as soon as you publish.
Cloudcraft Live instantly analyzes all the service relationships of your AWS environment, and reverse engineers a complete system architecture diagram.
Their powerful auto-layout and advanced AWS account scanning capabilities are also available to you as an API. Then via the "Terraform code export" (https://modules.tf/) will be generating infrastructure as Terraform configurations from visual diagrams created using Cloudcraft.
TF-#2 | Brainboard.co
With https://brainboard.co you could import your cloud infrastructure
and turn AWS environments into actionable visual Terraform infrastructure-as-code IaC.
They named this feature as "Terraform Reverse" , which allows users to import an infrastructure from your cloud credentials. :ledged: NOTE: This feature is in Beta and will be released soon for everyone.
The complete doc could be found here https://docs.brainboard.co/start/import-infrastructure
Top comments (0)