为什么函数 Fn::GetAtt 函数给我错误?
why the function Fn::GetAtt function give me error?
我尝试使用fn::GetAtt函数来计算权限和引用。我的 cloudformation json 是:
定义的资源部分为:
"Resources": {
"helloworld": {
"Properties": {
"AutoPublishAlias": "live",
"Handler": "index.handler",
"Runtime": "nodejs6.10",
"CodeUri": "s3://ss-sheng/src/helloWorld.zip",
"Role": {
"Ref": "dependrole"
},
"Timeout": 3,
"ReservedConcurrentExecutions": 5,
"Tags": {
"PROJECT": "My Point",
"COST_CENTRE": "6400073401",
"BUSINESS_UNIT": "My Programs",
"BUSINESS_CONTACT": "Greg Windsor",
"TIER": "Development"
}
},
"Type": "AWS::Serverless::Function"
},
"helloworldpermission": {
"DependsOn": "helloworld",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::Join": [
":",
[
{
"Ref": "helloworld"
},
{
"Fn::GetAtt": [
"helloworld",
"Version"
]
}
]
]
},
"Principal": "apigateway.amazonaws.com"
},
"Type": "AWS::Lambda::Permission"
}
}
我收到错误:
Template error: every Fn::GetAtt object requires two non-empty parameters, the resource name and the resource attribute
我已经给了他们两个参数 "helloworld" 和 "Version"。
为什么 lambda 函数仍然显示错误?
helloworld 引用无服务器函数 helloworld。
我用的是"Transform":"AWS::Serverless-2016-10-31",定义在cloud-formation文件的开头
对于 AWS::Serverless::Function
资源,您可以使用 Ref
访问 version
和 alias
更多信息,请参考以下内容link:
因此,而不是
{
"Fn::GetAtt": [
"helloworld",
"Version"
]
}
应该是,
{
"Fn::Ref": [
"helloworld",
"Version"
]
}
我尝试使用fn::GetAtt函数来计算权限和引用。我的 cloudformation json 是: 定义的资源部分为:
"Resources": {
"helloworld": {
"Properties": {
"AutoPublishAlias": "live",
"Handler": "index.handler",
"Runtime": "nodejs6.10",
"CodeUri": "s3://ss-sheng/src/helloWorld.zip",
"Role": {
"Ref": "dependrole"
},
"Timeout": 3,
"ReservedConcurrentExecutions": 5,
"Tags": {
"PROJECT": "My Point",
"COST_CENTRE": "6400073401",
"BUSINESS_UNIT": "My Programs",
"BUSINESS_CONTACT": "Greg Windsor",
"TIER": "Development"
}
},
"Type": "AWS::Serverless::Function"
},
"helloworldpermission": {
"DependsOn": "helloworld",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::Join": [
":",
[
{
"Ref": "helloworld"
},
{
"Fn::GetAtt": [
"helloworld",
"Version"
]
}
]
]
},
"Principal": "apigateway.amazonaws.com"
},
"Type": "AWS::Lambda::Permission"
}
}
我收到错误:
Template error: every Fn::GetAtt object requires two non-empty parameters, the resource name and the resource attribute
我已经给了他们两个参数 "helloworld" 和 "Version"。 为什么 lambda 函数仍然显示错误?
helloworld 引用无服务器函数 helloworld。
我用的是"Transform":"AWS::Serverless-2016-10-31",定义在cloud-formation文件的开头
对于 AWS::Serverless::Function
资源,您可以使用 Ref
version
和 alias
更多信息,请参考以下内容link:
因此,而不是
{
"Fn::GetAtt": [
"helloworld",
"Version"
]
}
应该是,
{
"Fn::Ref": [
"helloworld",
"Version"
]
}