Files
fn-serverless/fnctl/docs/lambda/import.md
Seif Lotfy سيف لطفي a396a26410 Add lambda documentation (#215)
* Add import documentation

* minor fix

* Add lambda introductions in the docs

* Add lambda test-function docs

* Add getting-started

* Added lambda docs for create-function

* fixes suggested by @ccirello

* Add lamba environment documentation

* quick fixes

* use 3 ticks and language for docs

* use 3 ticks and language

* Add missing lambda README.md

* link to iron/node in the envirtonment.md

* fix getting-started.md

* notate bash commands

* minor cleanup

* minor cleanup

* minor cleanup

* minor cleanup

* minor cleanup

* fnctl/docs: fix formatting in create.md
2016-11-06 09:13:57 -08:00

48 lines
2.2 KiB
Markdown

Import existing AWS Lambda functions
====================================
The [fnctl](https://github.com/iron-io/functions/fnctl/) tool includes a set of
commands to act on Lambda functions. Most of these are described in
[getting-started](./getting-started.md). One more subcommand is `aws-import`.
If you have an existing AWS Lambda function, you can use this command to
automatically convert it to a Docker image that is ready to be deployed on
other platforms.
### Credentials
To use this, either have your AWS access key and secret key set in config
files, or in environment variables. In addition, you'll want to set a default
region. You can use the `aws` tool to set this up. Full instructions are in the
[AWS documentation][awscli].
[awscli]: http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-config-files
### Importing
The aws-import command is constructed as follows:
```bash
fnclt lambda aws-import <arn> <region> <image>
```
* arn: describes the ARN formats which uniquely identify the AWS lambda resource
* region: region on which the lambda is hosted
* image: the name of the created docker image which should have the format <username>/<image-name>
Assuming you have a lambda with the following arn `arn:aws:lambda:us-west-2:123141564251:function:my-function`, the following command:
```bash
fnclt lambda aws-import arn:aws:lambda:us-west-2:123141564251:function:my-function us-east-1 user/my-function
```
will import the function code from the region `us-east-1` to a directory called `./my-function`. It will
then create a docker image called `my-function`.
Using Lambda with Docker Hub and IronFunctions requires that the Docker image be
named `<Docker Hub username>/<image name>`. This is used to uniquely identify
images on Docker Hub. Please use the `<Docker Hub username>/<image
name>` as the image name with `aws-import` to create a correctly named image.
If you only want to download the code, pass the `--download-only` flag. The
`--profile` flag is available similar to the `aws` tool to help
you tweak the settings on a command level. Finally, you can import a different version of your lambda function than the latest one
by passing `--version <version>.`