1
votes

There is something that I don't understand in the concept of Cloudformation import feature.

I have a Lambda function, lets call it "myLambdaFunc". "myLambdaFunc" is running and working.

Now I want to create a cloudFormation-stack to deploy the same Lambda.

So I followed this article - "Bringing Existing Resources Into CloudFormation Management".

My cloud formation file look like this:

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Resources" : {
    "LambdaImportTest2" : {
        "Type" : "AWS::Lambda::Function",
        "DeletionPolicy" : "Delete",
        "Properties" : {
        }
    }
  }
}

But when trying to run the import in cloudFormation I get an "IMPORT_FAILED" error, because "Property Handler cannot be empty."

The error makes sense because the Property is empty.

But this is where my confusion starts - I try to import an existing Lambda. I don't want to define a new Lambda.. So what should I put in the Property handler? what code should I set there?

1
@AssaelAzran Thanks. I know this guide. But this is my problem: What do I put in the required property "Code"? I expect it to be the code from the already running Lambda. Isn't it the meaning of importing existing resources to cloudformation?carmel
You created your lambda in your aws console. it is not a resource inside an existing cloud-formation stack.Assael Azran
i thought you created your lambda locally and you want to import it.Assael Azran
ok now i understand read this aws.amazon.com/blogs/aws/… try to omit properties fieldAssael Azran

1 Answers

0
votes

Ok.. I think I figured out the confusion..

The main goal of the import process is to import the existing resource configuration.

In the case of a Lambda function - the main part of the resource is NOT the "Code" property. It can be copied manually from the existing Lambda.

When running the import I'll get the Lambda configuration in a cloudformation-stack, and I guess that is the main advantage in the import process, not needing to configure the resource by hand.