diff --git a/README.md b/README.md index 0da6c97..ee179e3 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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.

-

\ No newline at end of file +

diff --git a/app/README.md b/app/README.md index 33350fa..d7efd03 100644 --- a/app/README.md +++ b/app/README.md @@ -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=` and `export 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 @@ -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 \ No newline at end of file +Here is an example project: https://github.com/rgfindl/functionci-demo diff --git a/app/_cim.yml b/app/_cim.yml index 969a3e9..9126cf4 100644 --- a/app/_cim.yml +++ b/app/_cim.yml @@ -46,6 +46,8 @@ lambda: functions: - function: ${stack.outputs.LambdaFunction} + aliases: + PROD: ${stack.outputs.LambdaFunctionAlias} zip_file: index.zip deploy: phases: diff --git a/app/cloudformation.yml b/app/cloudformation.yml index d64c9d0..594b7eb 100644 --- a/app/cloudformation.yml +++ b/app/cloudformation.yml @@ -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 # diff --git a/app/lib/slack.js b/app/lib/slack.js index c93808e..eeeb143 100644 --- a/app/lib/slack.js +++ b/app/lib/slack.js @@ -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) { @@ -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); @@ -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; @@ -218,4 +222,4 @@ functions.create_dialog = function(trigger_id, done) { ], done); }; -module.exports = functions; \ No newline at end of file +module.exports = functions; diff --git a/kms/README.md b/kms/README.md index 34ac3a8..fe12f96 100644 --- a/kms/README.md +++ b/kms/README.md @@ -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 @@ -22,4 +25,4 @@ Create a file called `encrypt.json` "awsProfile": "