All Projects β†’ nordcloud β†’ Serverless Kms Secrets

nordcloud / Serverless Kms Secrets

Licence: mit
πŸ”‘πŸ”β˜οΈ Serverless plugin to encrypt variables with KMS (DEPRECATED)

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Serverless Kms Secrets

Serverless Jest Plugin
Plugin for Serverless Framework which adds support for test-driven development using Jest
Stars: ✭ 111 (-4.31%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Wsgi
Serverless plugin to deploy WSGI applications (Flask/Django/Pyramid etc.) and bundle Python packages
Stars: ✭ 377 (+225%)
Mutual labels:  serverless-framework, serverless-plugin
serverless-dynamodb-ttl
⚑️ Serverless Plugin to set DynamoDB TTL
Stars: ✭ 16 (-86.21%)
Mutual labels:  serverless-framework, serverless-plugin
serverless-api-gateway-throttling
A plugin for the Serverless framework which configures throttling for API Gateway endpoints.
Stars: ✭ 54 (-53.45%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Appsync Plugin
serverless plugin for appsync
Stars: ✭ 804 (+593.1%)
Mutual labels:  serverless-framework, serverless-plugin
serverless-package-external
Add external folders to the deploy package πŸ“¦
Stars: ✭ 53 (-54.31%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Plugin Canary Deployments
Canary deployments for your Serverless application
Stars: ✭ 283 (+143.97%)
Mutual labels:  serverless-framework, serverless-plugin
serverless-cloudformation-sub-variables
Serverless framework plugin for easily supporting AWS CloudFormation Sub intrinsic function variables
Stars: ✭ 25 (-78.45%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Api Gateway Caching
A plugin for the Serverless framework which helps with configuring caching for API Gateway endpoints.
Stars: ✭ 92 (-20.69%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Step Functions
AWS Step Functions plugin for Serverless Framework ⚑️
Stars: ✭ 758 (+553.45%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Plugin Git Variables
⚑️ Expose git variables to serverless
Stars: ✭ 75 (-35.34%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (-56.03%)
Mutual labels:  serverless-framework, serverless-plugin
serverless-aws-static-file-handler
Easily serve static files with the Serverless Framework on AWS Lambda.
Stars: ✭ 43 (-62.93%)
Mutual labels:  serverless-framework, serverless-plugin
serverless-plugin-epsagon
Epsagon's plugin for Serverless Framework ⚑️
Stars: ✭ 53 (-54.31%)
Mutual labels:  serverless-framework, serverless-plugin
serverless-alexa-skills
Manage your Alexa Skills with Serverless Framework
Stars: ✭ 69 (-40.52%)
Mutual labels:  serverless-framework, serverless-plugin
serverless-rack
Serverless plugin to deploy Ruby Rack applications (Sinatra/Rails/Padrino/Cuba etc.) and bundle gems
Stars: ✭ 58 (-50%)
Mutual labels:  serverless-framework, serverless-plugin
serverless-modular
⚑️ serverless plugin for microservice code management and deployment.
Stars: ✭ 19 (-83.62%)
Mutual labels:  serverless-framework, serverless-plugin
serverless-fission
Use Fission through Serverless Framework https://serverless.com
Stars: ✭ 19 (-83.62%)
Mutual labels:  serverless-framework, serverless-plugin
Serverless Plugin Typescript
Serverless plugin for zero-config Typescript support
Stars: ✭ 611 (+426.72%)
Mutual labels:  serverless-framework, serverless-plugin
Plugins
Serverless Plugins – Extend the Serverless Framework with these community driven plugins –
Stars: ✭ 850 (+632.76%)
Mutual labels:  serverless-framework, serverless-plugin

Serverless KMS Secrets (DEPRECATED)

A Serverless Plugin for the Serverless Framework which helps with encrypting service secrets using the AWS Key Management Service (KMS)

THIS MODULE IS NO LONGER MAINTAINED. The best practice for managing secrets, also supported out-of-the-box by Serverless Framework, is to use the AWS SSM parameter store. See https://serverless.com/framework/docs/providers/aws/guide/variables/#reference-variables-using-the-ssm-parameter-store

Introduction

This plugins does the following:

  • It provides commands to encrypt and decrypt secrets with KMS

Installation and configuration

In your service root, run:

npm install --save-dev serverless-kms-secrets

Add the plugin to serverless.yml:

plugins:
  - serverless-kms-secrets

Configure the plugin into the custom block in serverless.yml. For example:

custom:
  serverless-kms-secrets:
    secretsFile: kms-secrets.${opt:stage, self:provider.stage}.${opt:region, self:provider.region}.yml (optional)
  kmsSecrets: ${file(kms-secrets.${opt:stage, self:provider.stage}.${opt:region, self:provider.region}.yml)}

By default, the plugin creates secrets to the file kms-secrets.[stage].[region].yml. This can be overriden with the secretsFile parameter in the serverless-kms-secrets configuration.

Add Decrypt permissions to your lambda function with e.g. this block in IamRoleStatements:

    - Effect: Allow
      Action:
      - KMS:Decrypt
      Resource: ${self:custom.kmsSecrets.keyArn} 

Usage

Creating KMS Key

Create a KMS key in AWS IAM service, under Encryption keys. Collect the key id, which is the remaining part of the key ARN.

Encrypting Variables

To encrypt a variable using the key defined in the configuration, enter

sls encrypt -n VARIABLE_NAME -v myvalue [-k keyId]

e.g.

sls encrypt -n SLACK_API_TOKEN -v xoxp-1234567890-1234567890-123467890-a12346 -k 999999-9999-99999-999

The keyid (-k) parameter is mandatory for the first encrypted variable, but optional for the later ones (will be read from the secrets file). The encrypted variable is written to your secrets file (kms-secrets.[stage].[region].yml by default)

You may also pack multiple secrets into one KMS encrypted string. This simplifies consuming the secrets in the Lambda function since all secrets can be decrypted with one single KMS.Decrypt call. To encrypt multiple secrets into one single string, use the following notation:

sls encrypt -n VARIABLE_NAME:SECRET_NAME -v myvalue [-k keyId]

e.g.

sls encrypt -n SECRETS:SLACK_API_TOKEN -v xoxp-1234567890-1234567890-123467890-a12346 -k 999999-9999-99999-999

Would encrypt and add the SLACK_API_TOKEN into the (JSON) secret SECRETS.

NOTE: you may get warnings about the missing kms-secrets file when encrypting your first variables for a specific stage / region. The warning will go away once the file has been created by the plugin.

Decrypting Variables

The variables in the secrets file can be decrypted using

sls decrypt [-n VARIABLE_NAME]

The -n option is optional. Without that, all variables are decrypted and displayed in clear text on the console.

Using variables

Pass the variables stored in the secrets file e.g. as environment variables using

  environment:
    MY_VARIABLE: ${self:custom.kmsSecrets.secrets.MY_VARIABLE}

The variable must be decrypted in the Lambda function using the KMS decrypt method. E.g.

kms.decrypt({
  CiphertextBlob: Buffer(process.env.MY_VARIABLE, 'base64')
}).promise()
.then(data => {
  const decrypted = String(data.Plaintext)
})

If MY_VARIABLE consists of multiple variables, decode it using

  const secrets = JSON.parse(decrypted);

TODO

  • Add support for sls deploy (deploy as KMS encrypted environment variables)
  • Ease configuration (KeyIds / Arns in various places)

Release History

  • 2019/02/24 - v1.0.4 - Fix issue with serverless 1.33
  • 2017/09/09 - v1.0.0 - Add support for multisecret structures
  • 2017/05/13 - v0.9.0 - Initial version

License

Copyright (c) 2017 Nordcloud, licensed for users and contributors under MIT license. https://github.com/nordcloud/serverless-kms-secrets/blob/master/LICENSE

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].