使用 IAM 策略文档对象列表作为 AWS::Serverless::Function 策略
Using List of IAM Policy Document Objects as AWS::Serverless::Function Policies
根据无服务器应用程序模型中 AWS::Serverless::Function
的 documentation,可以为 Policies
[=28] 指定 IAM 策略文档对象 (PDO) 列表=] 的资源。
但是,当我尝试定义 IAM PDO 时,Visual Studio 的 AWS 工具包标记语法错误:
这是我的 Resources
部分的完整示例:
"Resources": {
"Example" : {
"Type" : "AWS::Serverless::Function",
"Properties": {
"Handler": "Example::Example.Controllers.ExampleController::ExampleAction",
"Runtime": "dotnetcore2.0",
"CodeUri": "",
"MemorySize": 256,
"Timeout": 30,
"Policies": [{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
}],
"Events": {
"PutResource": {
"Type": "Api",
"Properties": {
"Path": "/{id}",
"Method": "GET"
}
}
}
}
}
}
我是不是哪里出错了,或者 SAM 或 AWS Toolkit 语法验证有问题?
我认为问题出在你的语法上,它应该是一个语句数组,因为可以有多个策略,如下所示,
"Statement":[
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
]
具有多个策略的示例如下所示,
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:Query"
],
"Resource": "arn:aws:dynamodb:${region}:*:table/${project}-songs-${dev}/*/*"
},
{
"Effect": "Allow",
"Action": [
"dynamodb:GetItem" ],
"Resource": "arn:aws:dynamodb:${region}:*:table/${project}-users-${dev}"
},
]
问题似乎是由 Visual Studio 和 AWS 工具包中的语法解析问题引起的。我在 GitHub 上提出了一个问题,你可以在这里跟踪它:https://github.com/aws/aws-sdk-net/issues/1001
我刚刚更新了 VS CloudFormation 架构。下次重新启动时问题应该会消失 Visual Studio.
根据无服务器应用程序模型中 AWS::Serverless::Function
的 documentation,可以为 Policies
[=28] 指定 IAM 策略文档对象 (PDO) 列表=] 的资源。
但是,当我尝试定义 IAM PDO 时,Visual Studio 的 AWS 工具包标记语法错误:
这是我的 Resources
部分的完整示例:
"Resources": {
"Example" : {
"Type" : "AWS::Serverless::Function",
"Properties": {
"Handler": "Example::Example.Controllers.ExampleController::ExampleAction",
"Runtime": "dotnetcore2.0",
"CodeUri": "",
"MemorySize": 256,
"Timeout": 30,
"Policies": [{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
}],
"Events": {
"PutResource": {
"Type": "Api",
"Properties": {
"Path": "/{id}",
"Method": "GET"
}
}
}
}
}
}
我是不是哪里出错了,或者 SAM 或 AWS Toolkit 语法验证有问题?
我认为问题出在你的语法上,它应该是一个语句数组,因为可以有多个策略,如下所示,
"Statement":[
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
]
具有多个策略的示例如下所示,
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:Query"
],
"Resource": "arn:aws:dynamodb:${region}:*:table/${project}-songs-${dev}/*/*"
},
{
"Effect": "Allow",
"Action": [
"dynamodb:GetItem" ],
"Resource": "arn:aws:dynamodb:${region}:*:table/${project}-users-${dev}"
},
]
问题似乎是由 Visual Studio 和 AWS 工具包中的语法解析问题引起的。我在 GitHub 上提出了一个问题,你可以在这里跟踪它:https://github.com/aws/aws-sdk-net/issues/1001
我刚刚更新了 VS CloudFormation 架构。下次重新启动时问题应该会消失 Visual Studio.