我正在学习 AWS 无服务器应用程序模型。我正在尝试以下模型:
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Resources:
MyLambdaFunction:
Type: 'AWS::Serverless::Function'
Properties:
Runtime: nodejs8.10
Handler: index.handler
CodeUri:
Bucket: artifacts-for-lambda
Key: my-lambda-package.zip
Events:
MySchedule:
Type: Schedule
Properties:
Schedule: rate(1 minute)
MyS3Upload:
Type: S3
Properties:
Bucket: !Ref MyS3Bucket
Events: s3:ObjectCreated:*
MyS3Bucket:
Type: 'AWS::S3::Bucket'
Properties:
BucketName: upload-something-here
这就是我运行它的方式:
aws cloudformation deploy
--capabilities CAPABILITY_NAMED_IAM
--template-file sam-template.yaml
--stack-name my-serverless-app
这是我收到的错误:
GetObject 时发生错误。S3 错误代码:永久重定向。S3 错误消息:存储桶位于此区域:us-east-1。请使用此区域重试请求(服务:AWSLambdaInternal;状态代码:400;错误代码:InvalidParameterValueException
us-east-2
是我的 AWS 配置文件的默认区域。
如果us-east-2
是我的默认区域,为什么我会收到此错误消息The bucket is in this region: us-east-1
?如何在无服务器脚本中为 S3 存储桶指定区域?