Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download sources for AWS Lambda from external source systems

I need to create simple terraform infrastructure and part of this infrastructure needs to create AWS Lambda with java Spring Boot application as source code.

I read documentation related to lambda and looks like right now terraform can only load sources from local file or from s3 bucket. In my case I store application jar file in Nexus repository(binary storage) and want to load source code/jar during Lambda creation from Nexus too.

Based on terraform documentation it has:

  • local provider that could only create files.
  • http provider that supports responses with Content-Type text/* or application/json and in my case I have application/java-archive
  • external provider expects json response and in my case I have archive.

no one of this approaches solve my problem. Of cause I can create bash file that will run wget command for jar file and then run terraform command. But this does not look pretty from my perspective. May be you can suggest any other solutions that would be more accurate and flexible.

like image 460
Aleksei Bulgak Avatar asked Jan 04 '18 08:01

Aleksei Bulgak


People also ask

How do I run a lambda function in AWS Lambda?

1. Open the Lambda section of the AWS Resources window. 2. Under Local Functions, open the context (right-click) menu for your function. 3. Choose Deploy. After deploying your function, you can run your code using the additional modules that you imported.

Can I use NPM with AWS Lambda?

A common scenario with AWS Lambda is the need to use an external library in your function (AWS SDK functions are available by default) such as Axios. However Lambda will not detect and install NPM packages for you automatically if you require them in your functions.

How to get the source of the Lambda layer?

You can get it from a Arn using the get-layer-version-by-arn function in the CLI. You can run the below command to get the source of the Lambda layer you requested.

How long does it take to upload AWS Lambda layer packages?

Ready-to-upload AWS Lambda Layer packages in under 2 minutes. Using a Lambda to create layers for our Lambdas AWS Cloud services, like AWS Lambda, are a flexible way to quickly deploy data solutions. But, handling packages and related dependencies can be frustrating when deploying complex Lambda infrastructure, even if you are using Lambda Layers.


1 Answers

The simplest solution is the one you have already suggested - wrap terraform in a parent command that first fetches the jar file - or even just document this as a required manual step / dependency. I believe this is fairly common.

Alternatively, if you really want to be provided with something for which there is no existing provider, you can create your own Terraform provider.

like image 152
duncanhall Avatar answered Oct 09 '22 03:10

duncanhall