Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ Here is an example project: https://github.com/rgfindl/functionci-demo
3. Install the [kms](kms/README.md) stack.
4. Install the [app](app/README.md) stack.

Note:
1. You will need 3 unique buckets (2 _cim.yml + 1 in cloudformation.yml). Currently if creation failed, CloudFormation / CIM won't automatically clean up for you since out of scope of CloudFormation. You have to manually delete them yourself.
2. Bear in mind KMS key would take minimum 7 days to delete even nothing refers to that key, in case you have KMS stack creation failure. Search and edit cloudformation.yml with different name would avoid this.

** If you fix or add anything please submit a Pull Request!!!

## Commands
Expand Down Expand Up @@ -189,4 +193,4 @@ When you commit changes to your Github repo CodePipeline is triggered. The firs
Now we are ready to deploy our build artifact to our Lambda.
<p align="left">
<img width="75%" src="docs/FunctionCI-Deploy-Fn.png">
</p>
</p>
17 changes: 13 additions & 4 deletions app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,18 @@ Create a [Github personal access token](https://github.com/settings/tokens) with


## Step 6 - Install the stack
Install the app stack using the following [CIM](https://github.com/thestackshack/cim) command: `cim stack-up`.

Deploy the Lambda using the following [CIM](https://github.com/thestackshack/cim) command: `cim deploy-lambda`.
Install the app stack using the following [CIM](https://github.com/thestackshack/cim) command (again, don't forget the dot in the end):
```
cim stack-up .
```

Deploy the Lambda using the following [CIM](https://github.com/thestackshack/cim) command:
```
cim lambda-publish
```
Note
1. `cim lambda-deploy` won't work since it will keep asking you alias / version even provided in cli and/or specified in cloudformation.yml.
2. Add `export AWS_REGION=<your aws region here>` and `export AWS_PROFILE=<your aws profile>` in case CIM keeps complaining region is missing on publish lambda.

Record the stack outputs, you will need them in the next 2 steps:
* SlackInteractiveComponentsUrl
Expand Down Expand Up @@ -87,4 +96,4 @@ If you want to use your bot in private channels you'll have to invite it. `/inv

Check out the [FunctionCI Commands](../README.md#commands) to get started building and deploying your Lambda's.

Here is an example project: https://github.com/rgfindl/functionci-demo
Here is an example project: https://github.com/rgfindl/functionci-demo
2 changes: 2 additions & 0 deletions app/_cim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ lambda:
functions:
-
function: ${stack.outputs.LambdaFunction}
aliases:
PROD: ${stack.outputs.LambdaFunctionAlias}
zip_file: index.zip
deploy:
phases:
Expand Down
18 changes: 18 additions & 0 deletions app/cloudformation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,24 @@ Resources:
GithubToken: !Ref GithubToken
ArtifactsBucket: !Ref ArtifactsBucket

#
# 'PROD' Alias -> Version 1
#
LambdaFunctionAlias:
Type: AWS::Lambda::Alias
Properties:
FunctionName: !Ref LambdaFunction
FunctionVersion: !GetAtt LambdaFunctionVersion.Version
Name: 'PROD'

#
# Create Lambda Version
#
LambdaFunctionVersion:
Type: AWS::Lambda::Version
Properties:
FunctionName: !Ref LambdaFunction

#
# Create the API Gateway
#
Expand Down
16 changes: 10 additions & 6 deletions app/lib/slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ functions.channels_list = function(params, done) {
'Authorization':'Bearer '+process.env.SlackBotOAuthToken
},
json: true,
method: 'POST',
body: {
limit: params.limit
method: 'GET',
qs: {
limit: params.limit,
exclude_archived: 1
}
};
if (params.cursor) {
Expand All @@ -36,7 +37,10 @@ functions.groups_list = function(params, done) {
'Authorization':'Bearer '+process.env.SlackBotOAuthToken
},
json: true,
method: 'GET'
method: 'GET',
qs: {
exclude_archived: 1
}
};
request(options, function(err, response, body) {
done(err, body);
Expand All @@ -50,7 +54,7 @@ functions.fetch_all_channels = function(params, done) {
function(channels, next_waterfall) {
var complete = false;
var params = {
limit: 200
limit: 100
};
async.until(function() {
return complete;
Expand Down Expand Up @@ -218,4 +222,4 @@ functions.create_dialog = function(trigger_id, done) {
], done);
};

module.exports = functions;
module.exports = functions;
7 changes: 5 additions & 2 deletions kms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ Creates a KMS Key to use when encrypting your secret credentials.

## Create Stack
- First update [_cim.yml](_cim.yml) and add the IAM users you wish to have access to encrypt and decrypt. Keep the `root` user. Make sure you use your AWS account ID.
- Create the stack: `cim stack-up`.
- Create the stack with (don't forget the dot in the end of line):
```
cim stack-up .
```
- Record the KMS Key ID in the stack output.

## Encrypt Secrets
Expand All @@ -22,4 +25,4 @@ Create a file called `encrypt.json`
"awsProfile": "<aws profile"
}
```
Use this command to perform the encryption : `kms-cli encrypt --file encrypt.json`
Use this command to perform the encryption : `kms-cli encrypt --file encrypt.json`