[英]AWS SAM Template - Error: Failed to parse template: while parsing a block mapping
我有這個模板:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
example
Parameters:
EnvironmentPrefix:
Type: String
Default: "test-"
Resources:
S3JsonLoggerFunction:
Type: AWS::Serverless::Function
Properties:
Handler: src/handlers/s3-json-logger.s3JsonLoggerHandler
Runtime: nodejs18.x
Architectures:
- x86_64
MemorySize: 128
Timeout: 60
Policies:
- S3ReadPolicy:
BucketName:
!Fn::ImportValue:
!Sub "${EnvironmentPrefix}example-bucket"
Events:
S3NewObjectEvent:
Type: S3
Properties:
Bucket:
!Fn::ImportValue:
!Sub "${EnvironmentPrefix}example-bucket"
Events: s3:ObjectCreated:*
Filter:
S3Key:
Rules:
- Name: prefix
Value: "changelog/"
為什么會失敗並出現此錯誤???
Error: Failed to parse template: while parsing a block mapping
in "<unicode string>", line 23, column 13:
BucketName:
^
expected <block end>, but found '<tag>'
in "<unicode string>", line 25, column 17:
!Sub "${EnvironmentPrefix}example-b ...
^
我一直盯着這個並將其與https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-policy-templates.html上的示例進行比較,但無法弄清楚是什么不同的!!!
我認為您的:Fn::ImportValue:
語法是錯誤的。
它應該只是Fn::ImportValue:
沒有!
,作為!
是Fn::
的簡稱。
Policies:
- S3ReadPolicy:
BucketName:
Fn::ImportValue:
!Sub "${EnvironmentPrefix}example-bucket"
文檔在這里: https ://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.