Skip to content

Serverless plugin to expand a KMS alias variable to the ARN of the KMS key

License

Notifications You must be signed in to change notification settings

serverless-plugins/serverless-kms-alias

Repository files navigation

serverless-kms-alias

NPM version node version

Serverless plugin to expand a KMS alias variable to the ARN of the KMS key

Usage

${kms:<alias>} will expand to the ARN of the kms key. The variable can be used anywhere that other Serverless variables are resolved.

Example - Provider kmsKeyArn

service: foo

provider:
  name: aws
  kmsKeyArn: '${kms:alias/aws/lambda}'
  runtime: nodejs16.x

plugins:
  - serverless-kms-alias

functions:
  foo:
    handler: foo.handler

Example - Function kmsKeyArn

service: foo
provider:
  name: aws
  runtime: nodejs16.x

plugins:
  - serverless-kms-alias

functions:
  foo:
    handler: foo.handler
    kmsKeyArn: '${kms:arn:aws:kms:${aws:region}:${aws:accountId}:alias/aws/lambda}'

Example - Disable the plugin

service: foo
provider:
  name: aws
  runtime: nodejs16.x

plugins:
  - serverless-kms-alias

custom:
  kmsAlias:
    enabled: false

functions:
  foo:
    handler: foo.handler
    kmsKeyArn: '${kms:arn:aws:kms:${aws:region}:${aws:accountId}:alias/aws/lambda}'