我有一个 serverless.yaml 文件,我正在尝试将 .env 文件中的变量连接到字符串的一部分,但没有成功。下面是一个例子:
.env file:
PHOTO_BUCKET=Images
.yaml file:
iamRoleStatements:
- Effect: "Allow"
Action:
- "s3:PutObject"
- "s3:GetObject"
Resource: "arn:aws:s3:::"${env:PHOTO_BUCKET}"/*"
我也试过
Resource: "arn:aws:s3:::${env:PHOTO_BUCKET}/*"
我得到的错误是can not read an implicit mapping pair; a colon is missed
。如果有人能告诉我正确的方向,我会很感激。
要修复A valid environment variable to satisfy the declaration 'env:PHOTO_BUCKET' could not be found
错误,请确保您已安装所需的dotenv 插件并将其包含到您的 yaml 中:
plugins:
- serverless-dotenv-plugin
要修复can not read an implicit mapping pair; a colon is missed
错误,请从资源中删除内部引号对:
iamRoleStatements:
- Effect: "Allow"
Action:
- "s3:PutObject"
- "s3:GetObject"
Resource: "arn:aws:s3:::${env:PHOTO_BUCKET}/*"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句