Search code examples
amazon-web-servicesaws-cloudformationdevopsinfrastructure

Generate cloudformation for exisiting resouces, load balancer migration


I was wondering if anybody has had any experience creating a cloudformation template from exisiting AWS resources.

I am currently trying to migrate from a classic elb to a alb using the wizard. However I already have cloudformation templates managed by github. Therefore I would need to add the alb in after it has been created. I tried using cloudformer but it doesn't appear to support alb whereas it does pickup classic.

Has anybody had experience migrating elbs and creating cloudformation templates from existing resources?

Many thanks!


Solution

  • AWS::ElasticLoadBalancingV2::LoadBalancer is one of the resources that can be imported into CloudForamtion. But sadly AWS::ElasticLoadBalancingV2::TargetGroup can't be imported.

    Importing is a try-and-see operation. It is not automated as many people expect it to be. The reason is that you have to manually create the template for the resources being imported. What's more, the attributes of the resources in the template created must match exactly existing resources.

    CloudFormer is not helpful these days. Its not maintained by AWS anymore and has been in beta for years.

    If you haven't tried importing anything before, the best way would be to start with AWS tutorial: Importing Existing Resources Into a Stack

    This way you can start with something simple, before you move to ALB with all its listeners and listener rules. Off course you have to create new Target Group as well as it can't be imported sadly.