【发布时间】:2019-04-21 01:08:14
【问题描述】:
对于 Lambda 函数的 ssm:GetParameter* 权限,是否有任何类似于 DynamoDBReadPolicy 的托管策略?我正在使用 aws-sam-cli 并尝试关注 this,但是当我尝试在使用 sam local start-api 时获取参数时,出现以下错误:
InvalidAction: The action or operation requested is invalid. Verify that the action is typed correctly.
这是我尝试获取参数的sn-p:
const ssm = new AWS.SSM();
const param = {
Name: "param1",
WithDecryption: true
};
const secret = await ssm.getParameter(param).promise();
相关模板部分如下。谢谢!
KeyAlias:
Type: AWS::KMS::Alias
Properties:
AliasName: 'param1Key'
TargetKeyId: !Ref Key
Key:
Type: AWS::KMS::Key
Properties:
KeyPolicy:
Id: default
Statement:
- Effect: Allow
Principal:
AWS: !Sub arn:aws:iam::${AWS::AccountId}:root
Action:
- 'kms:Create*'
- 'kms:Encrypt'
- 'kms:Describe*'
- 'kms:Enable*'
- 'kms:List*'
- 'kms:Put*'
- 'kms:Update*'
- 'kms:Revoke*'
- 'kms:Disable*'
- 'kms:Get*'
- 'kms:Delete*'
- 'kms:ScheduleKeyDeletion'
- 'kms:CancelKeyDeletion'
Resource: '*'
Sid: Allow root account all permissions except to decrypt the key
Version: 2012-10-17
LambdaFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ../
Handler: app.lambda
Runtime: nodejs8.10
Policies:
- DynamoDBReadPolicy:
TableName: !Ref Table
- KMSDecryptPolicy:
KeyId: !Ref Key
# I think I need the ssm policy here
【问题讨论】:
标签: amazon-web-services aws-lambda aws-serverless aws-sam-cli serverless-application-model