Skip to content

Commit

Permalink
Merge pull request #44 from calmwave-open-source/cees/create-containe…
Browse files Browse the repository at this point in the history
…r-function

Allow containers in create_function
  • Loading branch information
bernardd authored Jan 22, 2024
2 parents c527254 + 57cd9fb commit 953062e
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/ex_aws/lambda.ex
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,37 @@ defmodule ExAws.Lambda do
Create a function.
Runtime defaults to nodejs, as that is the only one available.
If options contains `package_type`, then if that is "Image" the function creates
a container function; else it will create a zipfile-based function. For a container,
the `handler` argument will be ignored.
"""
@spec create_function(
function_name :: binary,
handler :: binary,
zipfile :: binary
zipfile_or_container_uri :: binary
) :: ExAws.Operation.JSON.t()
@spec create_function(
function_name :: binary,
handler :: binary,
zipfile :: binary,
zipfile_or_container_uri :: binary,
opts :: create_function_opts
) :: ExAws.Operation.JSON.t()
def create_function(function_name, handler, zipfile, opts \\ []) do
def create_function(function_name, handler, zipfile_or_container_uri, opts \\ []) do
code =
if opts[:package_type] == "Image" do
%{"Code" => %{"ImageUri" => zipfile_or_container_uri}}
else
%{"Code" => %{"ZipFile" => zipfile_or_container_uri}, "Handler" => handler}
end

data =
opts
|> normalize_opts
|> Map.merge(%{
"FunctionName" => function_name,
"Handler" => handler,
"Code" => %{"ZipFile" => zipfile}
"FunctionName" => function_name
})
|> Map.merge(code)

request(:create_function, data, "/2015-03-31/functions")
end
Expand Down

0 comments on commit 953062e

Please sign in to comment.