How to create a cloud formation template from an existing AWS environment?

There is stack available in CloudFormation templates named CloudFormer. You can create AWS CloudFormation Templates from Existing AWS Resources by using this stack. Although, as it is in Beta version it might not be supported for all the resources. You can refer document for more information about CloudFormer:

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-using-cloudformer.html


Check the Github Former project. Former2 can generate not just CloudFormation but Terraform Troposphere templates, and CDK (typescript) from your existing AWS resources