SAM yaml template, importing the Load Balancer as existing resource

Viewed 345

I created API Gateway type HTTP. The integration for one of my routs is the load balancer from type “application”.

Right now, I am creating the Serverless Application Model (SAM) project. So, all this API Gateway except to the Load Balancer should be created from the yaml template of the SAM project. And this Load Balancer is created from another Cloud Formation stack. That is, the Load Balancer is already existing resource for my sam project. Hence, I need to use the Load Balancer as existing resource at my yaml template of the SAM project. That is, I need to use “Importing existing resources into a stack” feature https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-existing-stack.html .

Unfortunately, I did not understand how properly write this piece of my template to implement this feature. I tried do it from aws tutorials. Also, I did not find the template examples by the Google search.

And in this https://github.com/aws/serverless-application-model/issues/1335 tread in comment from Dec 20, 2019 even written, that “SAM does not support importing existing resources today”.

So, what can I do? All that I need is five lines at my sam template to import existing the Load Balancer. The one of them is "DeletionPolicy": "Retain" but what are the other? Help me write them.

AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: a Sample SAM Template for a
Globals:
  Function:
    Timeout: 30
Resources:
  BoardHttpApi:
    Type: AWS::Serverless::HttpApi
    Properties:
      StageName: Test
      CorsConfiguration: True
  LoadBalancer:
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      Type: application
      Scheme: internet-facing

Thanks.

0 Answers
Related