github.com/iron-io/functions@v0.0.0-20180820112432-d59d7d1c40b2/docs/lambda/import.md (about) 1 Import existing AWS Lambda functions 2 ==================================== 3 4 The [fn](https://github.com/iron-io/functions/fn/) tool includes a set of 5 commands to act on Lambda functions. Most of these are described in 6 [getting-started](./getting-started.md). One more subcommand is `aws-import`. 7 8 If you have an existing AWS Lambda function, you can use this command to 9 automatically convert it to a Docker image that is ready to be deployed on 10 other platforms. 11 12 ### Credentials 13 14 To use this, either have your AWS access key and secret key set in config 15 files, or in environment variables. In addition, you'll want to set a default 16 region. You can use the `aws` tool to set this up. Full instructions are in the 17 [AWS documentation][awscli]. 18 19 [awscli]: http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-config-files 20 21 ### Importing 22 23 The aws-import command is constructed as follows: 24 25 ```bash 26 fn lambda aws-import <arn> <region> <image> 27 ``` 28 29 * arn: describes the ARN formats which uniquely identify the AWS lambda resource 30 * region: region on which the lambda is hosted 31 * image: the name of the created docker image which should have the format <username>/<image-name> 32 33 Assuming you have a lambda with the following arn `arn:aws:lambda:us-west-2:123141564251:function:my-function`, the following command: 34 35 ```sh 36 fn lambda aws-import arn:aws:lambda:us-west-2:123141564251:function:my-function us-east-1 user/my-function 37 ``` 38 39 will import the function code from the region `us-east-1` to a directory called `./user/my-function`. Inside the directory you will find the `function.yml`, `Dockerfile`, and all the files needed for running the function. 40 41 Using Lambda with Docker Hub and IronFunctions requires that the Docker image be 42 named `<Docker Hub username>/<image name>`. This is used to uniquely identify 43 images on Docker Hub. Please use the `<Docker Hub username>/<image 44 name>` as the image name with `aws-import` to create a correctly named image. 45 46 If you only want to download the code, pass the `--download-only` flag. The 47 `--profile` flag is available similar to the `aws` tool to help 48 you tweak the settings on a command level. Finally, you can import a different version of your lambda function than the latest one 49 by passing `--version <version>.` 50 51 You can then deploy the imported lambda as follows: 52 ``` 53 ./fn deploy -d ./user/my-function user 54 ```` 55 Now the function can be reached via ```http://$HOSTNAME/r/user/my-function```