Skip to content

Kratus1985/serverless-offline-kms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

serverless-offline-kms

This Serverless plugin extends serverless-offline to emulates AWS KMS Invocations on your local machine to speed up your development cycles. To do so, it starts an HTTP server to invoke KMS using the AWS SDK. This going to return the same value that you pass as parameter.

Installation

First, add Serverless Plugin to your project:

npm install serverless-offline-kms --save-dev

Then inside your project's serverless.yml file add following entry to the plugins section: serverless-offline-kms. If there is no plugin section you will need to add it to the file.

It should look something like this:

plugins:
  - serverless-offline-kms
  - serverless-offline

Example

Run Serverless Offline

sls offline start

Invoke KMS using AWS SDK.

'use strict';

const {KMSClient, DecryptCommand} = require('@aws-sdk/client-kms');

module.exports.hello = async (event) => {

    const kms = new KMSClient({
        endpoint: "http://localhost:4001",
        region: 'us-east-1',
        credentials: {
            accessKeyId: 'ACCESS_KEY_ID',
            secretAccessKey: 'SECRET_ACCESS_KEY'
        }
    });

    const command = new DecryptCommand({
        CiphertextBlob: new Uint8Array(100)
    });

    const response = await kms.send(command);

    return {
        statusCode: 200,
        body: JSON.stringify(
            {
                message: 'Go Serverless v3.0! Your function executed successfully!',
                input: event,
                data: response
            },
            null,
            2
        ),
    };
};

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published