serverless-kms-secrets
serverless-kms-secrets copied to clipboard
Doesn't work with serverless invoke local
I followed the instructions to get the encryption and decryption working in my deployed functions, but it doesn't work with serverless invoke local
. Did I miss something?
Here are some excerpts from my serverless.yml
plugins:
- serverless-webpack
- serverless-kms-secrets
provider:
name: aws
runtime: nodejs6.10
iamRoleStatements:
- Effect: Allow
Action:
- KMS:Decrypt
Resource: ${self:custom.kmsSecrets.keyArn}
environment:
MY_VARIABLE_NAME: ${self:custom.kmsSecrets.secrets.MY_VARIABLE_NAME}
custom:
serverless-kms-secrets:
kmsSecrets: ${file(kms-secrets.${opt:stage, self:provider.stage}.${opt:region, self:provider.region}.yml)}
This works when I deploy and test the function, but not when I try to invoke it locally. Here's my command for invoking the function locally.
sls invoke local --function create-address --path test/requests/createAddressValid.json --stage dev --region us-east-1
Have I missed something or does it not work with serverless invoke local
?
When you invoke local
, you're not executing in a Lambda, so the Decrypt permissions don't apply.