fn: rename from fnctl (#321)

* fn: rename from fnctl

* fn: predicting the release version for installer

* fn: predicting the release version for installer
This commit is contained in:
C Cirello
2016-11-21 17:24:26 +01:00
committed by GitHub
parent 0343c4990c
commit c0512a4cbd
45 changed files with 172 additions and 172 deletions

View File

@@ -25,7 +25,7 @@ write a simple function and have an "executable" ready to go.
## How does it work?
We provide base Docker images for the various runtimes that AWS Lambda
supports. The `fnctl` tool helps package up your Lambda function into
supports. The `fn` tool helps package up your Lambda function into
a Docker image layered on the base image. We provide a bootstrap script and
utilities that provide a AWS Lambda environment to your code. You can then run
the Docker image on any platform that supports Docker. This allows you to
@@ -35,7 +35,7 @@ easily move Lambda functions to any cloud provider, or host it yourself.
Write, package and run your Lambda functions with our [Getting started
guide](./getting-started.md). [Here is the environment](./environment.md) that
Lambda provides. `fnctl lambda` lists the commands to work with Lambda
Lambda provides. `fn lambda` lists the commands to work with Lambda
functions locally.
You can [import](./import.md) existing Lambda functions hosted on Amazon!

View File

@@ -23,13 +23,13 @@ This can be done as follows:
export aws_access_key_id=<access-key>
export aws_secret_access_key=<secret_key>
./fnctl lambda create-function <user>/s3 nodejs example.run examples/s3/example.js examples/s3/example-payload.json --config aws_access_key_id --config aws_secret_access_key
./fn lambda create-function <user>/s3 nodejs example.run examples/s3/example.js examples/s3/example-payload.json --config aws_access_key_id --config aws_secret_access_key
```
or
```sh
./fnctl lambda create-function <user>/s3 nodejs example.run ../../lambda/examples/s3/example.js ../../lambda/examples/s3/example-payload.json --config aws_access_key_id=<access-key> --config aws_secret_access_key=<secret_key>
./fn lambda create-function <user>/s3 nodejs example.run ../../lambda/examples/s3/example.js ../../lambda/examples/s3/example-payload.json --config aws_access_key_id=<access-key> --config aws_secret_access_key=<secret_key>
```
The various AWS SDKs will automatically pick these up.

View File

@@ -1,10 +1,10 @@
# Creating Docker images out of Lambda functions
Docker images created by running the `create-function` subcommand on a Lambda function are ready to execute.
Docker images created by running the `create-function` subcommand on a Lambda function are ready to execute.
You can convert any Lambda function of type nodejs 0.10, python 2.7 and Java 8 into an
IronFunction compatible Docker Image as follows:
```bash
fnctl lambda create-function <name> <runtime> <handler> <files...>
fn lambda create-function <name> <runtime> <handler> <files...>
```
* name: the name of the created docker image which should have the format `<username>/<image-name>`
@@ -17,6 +17,6 @@ fnctl lambda create-function <name> <runtime> <handler> <files...>
e.g:
```bash
fnctl lambda create-function irontest/node-exec:1 nodejs node_exec.handler node_exec.js
fn lambda create-function irontest/node-exec:1 nodejs node_exec.handler node_exec.js
```

View File

@@ -2,8 +2,8 @@
This guide will walk you through creating and testing a simple Lambda function.
We need the the `fnctl` tool for the rest of this guide. You can install it
by following [these instructions](https://github.com/iron-io/function/fnctl).
We need the the `fn` tool for the rest of this guide. You can install it
by following [these instructions](https://github.com/iron-io/function/fn).
*For this getting started we are assuming you already have working lambda function code available, if not head to the [import instructions] (import.md) and skip the next section.*
@@ -13,21 +13,21 @@ Let's convert the `hello_world` AWS Lambda example to Docker.
```python
def my_handler(event, context):
message = 'Hello {} {}!'.format(event['first_name'],
event['last_name'])
return {
message = 'Hello {} {}!'.format(event['first_name'],
event['last_name'])
return {
'message' : message
}
}
```
Create an empty directory for your project and save this code in a file called
`hello_world.py`.
Now let's use `fnctl`'s Lambda functionality to create a Docker image. We can
Now let's use `fn`'s Lambda functionality to create a Docker image. We can
then run the Docker image with a payload to execute the Lambda function.
```sh
$ fnctl lambda create-function irontest/hello_world:1 python2.7 hello_world.my_handler hello_world.py
$ fn lambda create-function irontest/hello_world:1 python2.7 hello_world.my_handler hello_world.py
Creating directory: irontest/hello_world:1 ... OK
Creating Dockerfile: irontest/hello_world:1/Dockerfile ... OK
Copying file: irontest/hello_world/hello_world:1.py ... OK
@@ -40,23 +40,23 @@ As you can see, this is very similar to creating a Lambda function using the
your deployment environment to use different versions. The handler is
the name of the function to run, in the form that python expects
(`module.function`). Where you would package the files into a `.zip` to upload
to Lambda, we just pass the list of files to `fnctl`.
to Lambda, we just pass the list of files to `fn`.
## Publishing the function to IronFunctions
Next we want to publish the function to our IronFunctions
```sh
$ fnctl publish -v -f -d ./irontest
$ fn publish -v -f -d ./irontest
publishing irontest/hello_world:1/function.yaml
Sending build context to Docker daemon 4.096 kB
Step 1 : FROM iron/lambda-python2.7
latest: Pulling from iron/lambda-python2.7
c52e3ed763ff: Pull complete
789cf808491a: Pull complete
d1b635efed57: Pull complete
fe23c3dbcfa8: Pull complete
63c874a9687e: Pull complete
a6d462dae1df: Pull complete
c52e3ed763ff: Pull complete
789cf808491a: Pull complete
d1b635efed57: Pull complete
fe23c3dbcfa8: Pull complete
63c874a9687e: Pull complete
a6d462dae1df: Pull complete
Digest: sha256:c5dde3bf3be776c0f6b909d4ad87255a0af9b6696831fbe17c5f659655a0494a
Status: Downloaded newer image for iron/lambda-python2.7:latest
---> 66d3adf47835
@@ -69,15 +69,15 @@ Next we want to publish the function to our IronFunctions
Removing intermediate container 318da1bba060
Successfully built db9b9644168e
The push refers to a repository [docker.io/irontest/hello_world:1]
5d9d142e21b2: Pushed
11d8145d6038: Layer already exists
23885f85dbd0: Layer already exists
6a350a8d14ee: Layer already exists
e67f7ef625c5: Layer already exists
321db514ef85: Layer already exists
6102f0d2ad33: Layer already exists
5d9d142e21b2: Pushed
11d8145d6038: Layer already exists
23885f85dbd0: Layer already exists
6a350a8d14ee: Layer already exists
e67f7ef625c5: Layer already exists
321db514ef85: Layer already exists
6102f0d2ad33: Layer already exists
latest: digest: sha256:5926ff413f134fa353e4b42f2d4a0d2d4f5b3a39489cfdf6dd5b4a63c4e40dee size: 1784
updating API with appName: irontest route: /hello_world:1 image: irontest/hello_world:1
updating API with appName: irontest route: /hello_world:1 image: irontest/hello_world:1
path result
irontest/hello_world:1/function.yaml done
```
@@ -100,22 +100,22 @@ The `test-function` subcommand can launch the Dockerized function with the
right parameters.
```sh
$ fnctl lambda test-function irontest/hello_world:1 --payload '{ "first_name": "Jon", "last_name": "Snow" }'
$ fn lambda test-function irontest/hello_world:1 --payload '{ "first_name": "Jon", "last_name": "Snow" }'
{"message": "Hello Jon Snow!"}
```
You should see the output.
You should see the output.
## Calling the function from IronFunctions
The `fnctl call` command can call the published version with a given payload.
The `fn call` command can call the published version with a given payload.
```sh
$ echo '{ "first_name": "Jon", "last_name": "Snow" }' | ./fnctl call irontest /hello_world:1
$ echo '{ "first_name": "Jon", "last_name": "Snow" }' | ./fn call irontest /hello_world:1
{"message": "Hello Jon Snow!"}
```
You should see the output.
You should see the output.
## Commands documentation

View File

@@ -1,7 +1,7 @@
Import existing AWS Lambda functions
====================================
The [fnctl](https://github.com/iron-io/functions/fnctl/) tool includes a set of
The [fn](https://github.com/iron-io/functions/fn/) 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`.
@@ -23,7 +23,7 @@ region. You can use the `aws` tool to set this up. Full instructions are in the
The aws-import command is constructed as follows:
```bash
fnctl lambda aws-import <arn> <region> <image>
fn lambda aws-import <arn> <region> <image>
```
* arn: describes the ARN formats which uniquely identify the AWS lambda resource
@@ -33,7 +33,7 @@ fnctl lambda aws-import <arn> <region> <image>
Assuming you have a lambda with the following arn `arn:aws:lambda:us-west-2:123141564251:function:my-function`, the following command:
```sh
fnctl lambda aws-import arn:aws:lambda:us-west-2:123141564251:function:my-function us-east-1 user/my-function
fn 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 `./user/my-function`. Inside the directory you will find the `function.yml`, `Dockerfile`, and all the files needed for running the function.
@@ -50,6 +50,6 @@ by passing `--version <version>.`
You can then publish the imported lambda as follows:
```
./fnctl publish -d ./user/my-function
./fn publish -d ./user/my-function
````
Now the function can be reached via ```http://$HOSTNAME/r/user/my-function```

View File

@@ -11,7 +11,7 @@ docker run
An example of a valid `test-function` command would look as follows:
```
fnctl lambda test-function user/my-function --payload='{"firstName":"John", "lastName":"Yo" }'
fn lambda test-function user/my-function --payload='{"firstName":"John", "lastName":"Yo" }'
```
## Payload