forked from serverless/serverless
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
099cab7
commit 932cb77
Showing
1,485 changed files
with
252,665 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
Servant Command Line Interface | ||
================================= | ||
|
||
Develop, test and upload Servant Extensions onto AWS Lambda with a few simple commands. | ||
|
||
npm install servant-cli -g | ||
|
||
Commands | ||
================================= | ||
Make sure you've completed the set-up below and you are running these commands in your Servant Extension's root folder: | ||
|
||
$ cd my_servant_extension | ||
|
||
####servant init | ||
Creates Servant Extension Boilerplate Files in the current directory. | ||
|
||
$ servant init | ||
|
||
####servant command -n *command_name* -i *command_id* | ||
Creates a Servant Command and boilerplate files for that command. Specify the Command's name after the **-n**. Paste in the Command's name after the **-i**. | ||
|
||
$ servant command -n example_command -i com_DJa109 | ||
|
||
####servant run -n *command_name* | ||
Run the Command locally and seed it with the event.json data that is in its command folder. specify ** | ||
|
||
$ servant run -n example_command | ||
|
||
####servant deploy | ||
Deploys your entire Servant Extension to AWS Lambda as a single AWS Lambda Function. This includes zipping and uploading all of your Extension's files. | ||
|
||
$ servant deploy | ||
|
||
Set-Up | ||
================================= | ||
|
||
If you haven't set up your AWS Account yet to work with Lambda, here is how to do it perfectly. Register or sign in to your Amazon Web Services Account and go to the IAM (Identity & Access Management) service and then click on Policies because we're going to make 2 access policies: | ||
|
||
|
||
#####Servant Lambda Access Policy | ||
|
||
Click 'Create Policy' then select 'Create Your Own Policy' and enter in the following: | ||
|
||
Policy Name: | ||
servant_lambda_access_policy | ||
|
||
Policy Description: | ||
Gives Servant permission to call your Lambda functions. | ||
|
||
Paste in this Policy Document: | ||
|
||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"lambda:*" | ||
], | ||
"Resource": "*" | ||
}, | ||
{ | ||
"Sid": "Stmt1404366560000", | ||
"Effect": "Allow", | ||
"Action": [ | ||
"iam:PassRole" | ||
], | ||
"Resource": [ | ||
"arn:aws:iam::149631484542:role/servant_lambda" | ||
] | ||
} | ||
] | ||
} | ||
|
||
#####Servant Lambda Resources Policy | ||
|
||
Now, let's create the second policy. In the Policies screen, click 'Create Policy' then select 'Create Your Own Policy' and enter in the following: | ||
|
||
Policy Name: | ||
servant_lambda_resources_policy | ||
|
||
Policy Description: | ||
Gives the lambda function containing your Servant Extension access to call useful AWS resources like dynamodb and s3. | ||
|
||
Paste in this Policy Document: | ||
|
||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"cloudwatch:*", | ||
"cognito-identity:ListIdentityPools", | ||
"cognito-sync:GetCognitoEvents", | ||
"cognito-sync:SetCognitoEvents", | ||
"dynamodb:*", | ||
"iam:ListAttachedRolePolicies", | ||
"iam:ListRolePolicies", | ||
"iam:ListRoles", | ||
"iam:PassRole", | ||
"kinesis:DescribeStream", | ||
"kinesis:ListStreams", | ||
"kinesis:PutRecord", | ||
"lambda:*", | ||
"logs:*", | ||
"s3:*", | ||
"sns:ListSubscriptions", | ||
"sns:ListSubscriptionsByTopic", | ||
"sns:ListTopics", | ||
"sns:Subscribe", | ||
"sns:Unsubscribe" | ||
], | ||
"Resource": "*" | ||
} | ||
] | ||
} | ||
|
||
Now, in the IAM section, go to Users and create a new User called `servant`. In that User, click 'Attach Policy', and then search for `servant_lambda_access_policy`. Select it and attach it to the User. | ||
|
||
After the policy is attached, while viewing the `servant` User, find the 'Access Keys' section, click 'Create Access Key' and copy the `Access Key ID` and the `Secret Access Key`. You will need these shortly. | ||
|
||
Next, in the IAM section, go to Roles and create a new Role called `servant_lambda`. In that Role, click 'Attach Policy', and then search for `servant_lambda_resources_policy`. Select it and attach it to the Role. | ||
|
||
After the policy is attached, while viewing the `servant_lambda` Role, copy the `Role ARN` and save it with the Access Keys you saved earlier. You will need this and the Access Keys shortly. | ||
|
||
You're done with AWS! Whew! Hopefully that wasn't too bad. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env node | ||
|
||
var dotenv = require('dotenv'); | ||
var JAWS = require('../lib/main.js'); | ||
var program = require('commander'); | ||
var shortid = require('shortid'); | ||
|
||
// Load ENV Variables | ||
dotenv.load(); | ||
|
||
var AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID || 'missing'; | ||
var AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET_ACCESS_KEY || 'missing'; | ||
var AWS_REGION = process.env.AWS_REGION || 'us-east-1,us-west-2,eu-west-1'; | ||
var AWS_FUNCTION_NAME = process.env.AWS_FUNCTION_NAME || 'new_function'; | ||
var AWS_HANDLER = process.env.AWS_HANDLER || 'index.handler'; | ||
var AWS_MODE = 'event'; | ||
var AWS_ROLE = process.env.AWS_ROLE_ARN || process.env.AWS_ROLE || 'missing'; | ||
var AWS_MEMORY_SIZE = process.env.AWS_MEMORY_SIZE || 128; | ||
var AWS_TIMEOUT = process.env.AWS_TIMEOUT || 60; | ||
var AWS_DESCRIPTION = process.env.AWS_DESCRIPTION || ''; | ||
var AWS_RUNTIME = process.env.AWS_RUNTIME || 'nodejs'; | ||
var AWS_FUNCTION_VERSION = process.env.AWS_FUNCTION_VERSION | ||
|
||
|
||
|
||
/** | ||
* Deploy | ||
* - Deploys the Lambda Function to AWS Lambda | ||
*/ | ||
|
||
program | ||
.version(JAWS.version) | ||
.command( 'deploy' ) | ||
.description( 'Deploy your application to Amazon Lambda' ) | ||
.option( '-a, --accessKey [' + AWS_ACCESS_KEY_ID + ']', 'AWS Access Key', AWS_ACCESS_KEY_ID ) | ||
.option( '-s, --secretKey [' + AWS_SECRET_ACCESS_KEY + ']', 'AWS Secret Key', AWS_SECRET_ACCESS_KEY ) | ||
.option( '-r, --region [' + AWS_REGION + ']', 'AWS Region', AWS_REGION ) | ||
.option( '-n, --functionName [' + AWS_FUNCTION_NAME + ']', 'Lambda FunctionName', AWS_FUNCTION_NAME ) | ||
.option( '-h, --handler [' + AWS_HANDLER + ']', 'Lambda Handler {index.handler}', AWS_HANDLER ) | ||
.option( '-c, --mode [' + AWS_MODE + ']', 'Lambda Mode', AWS_MODE ) | ||
.option( '-o, --role [' + AWS_ROLE + ']', 'Amazon Role ARN', AWS_ROLE ) | ||
.option( '-m, --memorySize [' + AWS_MEMORY_SIZE + ']', 'Lambda Memory Size', AWS_MEMORY_SIZE ) | ||
.option( '-t, --timeout [' + AWS_TIMEOUT + ']', 'Lambda Timeout', AWS_TIMEOUT ) | ||
.option( '-d, --description [' + AWS_DESCRIPTION + ']', 'Lambda Description', AWS_DESCRIPTION ) | ||
.option( '-u, --runtime [' + AWS_RUNTIME + ']', 'Lambda Runtime', AWS_RUNTIME ) | ||
.option( '-v, --version [' + AWS_FUNCTION_VERSION + ']', 'Lambda Function Version', AWS_FUNCTION_VERSION ) | ||
.action( function( prg ) { | ||
JAWS.deploy( prg ); | ||
}); | ||
|
||
|
||
/** | ||
* Run | ||
* - Runs the Lambda Function locally | ||
*/ | ||
|
||
program | ||
.version( JAWS.version ) | ||
.command( 'run' ) | ||
.description( 'Run your Amazon Lambda application locally' ) | ||
.action( function( prg ) { | ||
JAWS.run( prg ); | ||
}); | ||
|
||
|
||
/** | ||
* Server | ||
* - Starts the webserver for the application | ||
*/ | ||
|
||
program | ||
.version( JAWS.version ) | ||
.command( 'server' ) | ||
.description( 'Start your server' ) | ||
.action( function( prg ) { | ||
JAWS.server( prg ); | ||
}); | ||
|
||
|
||
program.parse( process.argv ); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.