如何指定S3 bucket region SAM模板
How to specify S3 bucket region SAM template
我正在学习 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 存储桶指定区域?
汤姆,
我在我从事的一个项目中使用了 SAM。你可以这样使用它:
sam package --template-file template.yml \
--output-template-file packaged.yml \
--s3-bucket developing-sam-applications
--region YOUR_REGION
此外,您可以使用此命令对指定区域进行部署:
sam deploy --template-file packaged.yml \
--stack-name developing-sam-applications \
--capabilities CAPABILITY_IAM
--region YOUR_REGION
注意:请确保您在同一区域中拥有存储桶和功能。如果你想部署在不同的地区,你需要在那个地区有一个桶。
我正在学习 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 存储桶指定区域?
汤姆, 我在我从事的一个项目中使用了 SAM。你可以这样使用它:
sam package --template-file template.yml \
--output-template-file packaged.yml \
--s3-bucket developing-sam-applications
--region YOUR_REGION
此外,您可以使用此命令对指定区域进行部署:
sam deploy --template-file packaged.yml \
--stack-name developing-sam-applications \
--capabilities CAPABILITY_IAM
--region YOUR_REGION
注意:请确保您在同一区域中拥有存储桶和功能。如果你想部署在不同的地区,你需要在那个地区有一个桶。