Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
amowu committed Jan 4, 2016
2 parents ade9204 + d85acd9 commit 02271ed
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 71 deletions.
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,17 @@ This project was built with Ryan Ray's repo [slack-lambda-weather](https://githu
### Prerequisites

* Install [AWS CLI](https://aws.amazon.com/cli/)
* Execution Role ARN for your AWS Lambda
* Create a `config.json` based on `config.sample.json`. This file is gitignored by default because this is where you would put any API key's and other secret info that your lambda may need.
* Create a `config.json` based on `config.sample.json`. This file is gitignored by default because this is where you would put any API key's, AWS settings, and other secret info that your lambda may need.
* [Google Knowledge Graph Search API](https://developers.google.com/knowledge-graph/) API key, and paste it to `config.json`.

### AWS Lambda

> Lambda is based on EC2 and allows you to deploy and execute your code (Node.js, Java, Python) without having to provision servers.
First build and create your Lambda function on AWS:
Deploy and update your Lambda code:

```sh
npm run create LAMBDA_FUNCTION_NAME EXECUTION_ROLE_ARN
```

> Before you can create your Lambda you need to create an execution role. If you did any of the Lambda hello world tutorials in the AWS console you should already have a role created. Either way you need to goto the [IAM Management Console - Roles](https://console.aws.amazon.com/iam/home#roles). Get the ARN of `lambda_basic_execution` or create a new role based on `role.example.json` and get the ARN from that. The full ARN looks something like `arn:aws:iam::YOUR_ACCOUNT_ID:role/lambda_basic_execution`.
Build and deploy to update your Lambda code:

```sh
npm run deploy LAMBDA_FUNCTION_NAME
npm start
```

### AWS API Gateway
Expand Down
8 changes: 8 additions & 0 deletions config.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"AWS": {
"ACCOUNT_ID": "YOUR_AWS_ACCOUNT_ID",
"LAMBDA_FUNCTION_NAME": "YOUR_LAMBDA_FUNCTION_NAME",
"LAMBDA_HANDLER": "index.handler",
"LAMBDA_MEMORY_SIZE": 128,
"LAMBDA_REGION": "us-east-1",
"LAMBDA_TIMEOUT": 3
},
"GOOGLE_API_KEY": "YOUR_GOOGLE_API_KEY",
"SLASH_COMMANDS_TOKEN": "YOUR_SLACK_SLASH_COMMAND"
}
42 changes: 42 additions & 0 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import del from 'del'
import gulp from 'gulp'
import lambda from 'gulp-awslambda'
import gutil from 'gulp-util'
import zip from 'gulp-zip'
import runSequence from 'run-sequence'
import webpack from 'webpack'

import config from './config.json'

gulp.task('clean', () => del('dist'))

gulp.task('webpack', done => {
webpack(require('./webpack.config.js'), (error) => {
if(error) throw new gutil.PluginError('webpack', error)
done()
})
})

gulp.task('zip', () => {
return gulp.src('dist/*')
.pipe(zip('index.zip'))
.pipe(gulp.dest('dist'))
})

gulp.task('build', done =>
runSequence('clean', 'webpack', 'zip', done)
)

gulp.task('default', ['build'], () =>
gulp.src('dist/index.zip')
.pipe(lambda({
FunctionName: config.AWS.LAMBDA_FUNCTION_NAME,
Handler: config.AWS.LAMBDA_HANDLER,
MemorySize: config.AWS.LAMBDA_MEMORY_SIZE,
Role: `arn:aws:iam::${config.AWS.ACCOUNT_ID}:role/lambda_basic_execution`,
Runtime: 'nodejs',
Timeout: config.AWS.LAMBDA_TIMEOUT
},{
region: config.AWS.LAMBDA_REGION
}))
)
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"name": "slack-lambda-google",
"version": "0.2.0",
"version": "0.3.0",
"description": "A serverless Slack Slash Commands to integrate Google Knowledge Graph API using AWS Lambda and AWS API Gateway",
"main": "index.js",
"scripts": {
"build": "./scripts/build.sh",
"create": "./scripts/create.sh",
"deploy": "./scripts/deploy.sh"
"start": "gulp",
"build": "gulp build"
},
"author": "Amo Wu <amo260@gmail.com>",
"license": "Apache-2.0",
Expand All @@ -24,9 +23,13 @@
"babel-plugin-transform-flow-strip-types": "^6.3.15",
"babel-preset-es2015": "^6.3.13",
"bluebird": "^3.1.1",
"del": "^2.2.0",
"gulp": "^3.9.0",
"gulp-awslambda": "^0.3.0",
"gulp-util": "^3.0.7",
"gulp-zip": "^3.0.2",
"json-loader": "^0.5.4",
"run-sequence": "^1.1.5",
"webpack": "^1.12.9"
}
}
23 changes: 0 additions & 23 deletions scripts/build.sh

This file was deleted.

19 changes: 0 additions & 19 deletions scripts/create.sh

This file was deleted.

13 changes: 0 additions & 13 deletions scripts/deploy.sh

This file was deleted.

0 comments on commit 02271ed

Please sign in to comment.