我嘗試關注這個研討會https://gitflow-codetools.workshop.aws/en/,一切都很好,但是當我嘗試使用 cloudformation 創建 lambda 時,出現錯誤:
Resource handler returned message: "Error occurred while GetObject. S3 Error Code:
PermanentRedirect. S3 Error Message: The bucket is in this region:
us-east-1. Please use this region to retry the request (Service: Lambda,
Status Code: 400, Request ID: xxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxx,
Extended Request ID: null)" (RequestToken: xxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxx, HandlerErrorCode: InvalidRequest)
我在本次研討會中使用eu-west-1,但我不明白為什么 cloudformation 在us-east-1 中創建存盤桶。
當我在 us-east-1 中部署 cloudformation 時,我沒有收到此錯誤。
知道如何避免這個錯誤嗎?
模板如下所示:
AWSTemplateFormatVersion: '2010-09-09'
Resources:
LambdaRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: 'sts:AssumeRole'
Path: /
ManagedPolicyArns:
- arn:aws:iam::aws:policy/IAMFullAccess
- arn:aws:iam::aws:policy/AWSLambda_FullAccess
- arn:aws:iam::aws:policy/AWSCodeCommitReadOnly
- arn:aws:iam::aws:policy/AWSCodePipelineFullAccess
- arn:aws:iam::aws:policy/CloudWatchEventsFullAccess
- arn:aws:iam::aws:policy/AWSCloudFormationFullAccess
PipelineCreateLambdaFunction:
Type: 'AWS::Lambda::Function'
Properties:
FunctionName: 'gitflow-workshop-create-pipeline'
Description: 'Lambda Function to create pipelines on branch creation'
Code:
S3Bucket: 'aws-workshop-gitflow'
S3Key: 'pipeline-create.zip'
Handler: 'pipeline-create.lambda_handler'
Runtime: 'python3.7'
Role:
Fn::GetAtt:
- LambdaRole
- Arn
PipelineCreateLambdaPermission:
Type: 'AWS::Lambda::Permission'
DependsOn: PipelineCreateLambdaFunction
Properties:
Action: 'lambda:InvokeFunction'
Principal: "codecommit.amazonaws.com"
FunctionName: 'gitflow-workshop-create-pipeline'
PipelineDeleteLambdaFunction:
Type: 'AWS::Lambda::Function'
Properties:
FunctionName: 'gitflow-workshop-delete-pipeline'
Description: 'Lambda Function to delete pipelines on branch deletion'
Code:
S3Bucket: 'aws-workshop-gitflow'
S3Key: 'pipeline-delete.zip'
Handler: 'pipeline-delete.lambda_handler'
Runtime: 'python3.7'
Role:
Fn::GetAtt:
- LambdaRole
- Arn
PipelineDeleteLambdaPermission:
Type: 'AWS::Lambda::Permission'
DependsOn: PipelineDeleteLambdaFunction
Properties:
Action: 'lambda:InvokeFunction'
Principal: "codecommit.amazonaws.com"
FunctionName: 'gitflow-workshop-delete-pipeline'
uj5u.com熱心網友回復:
首先,Lambda 和 S3 需要在同一區域。
其次,看起來您不是存盤桶所有者(您還沒有通過查看模板自己創建存盤桶)。
這意味著,您用來從中檢索 Lambda 源代碼的存盤桶是(我想來自研討會),并且他們決定在區域 us-east-1 中創建該存盤桶。強制您也在 us-east-1 區域部署您的堆疊(如果您想參加研討會)。
但是,如果您真的想將此堆疊部署到 eu-west-1 呢?
這意味著您需要在區域 eu-west-1 中創建一個存盤桶,并將車間存盤桶中的物件復制到新創建的存盤桶中,并更新您的 CloudFormation 模板以指向并從新創建的存盤桶中檢索 Lambda 源代碼(注意您可能需要以不同的方式命名存盤桶,因為存盤桶名稱是全域共享的)。
我希望這有點清楚。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/371304.html
標籤:亚马逊网络服务 亚马逊-s3 aws-lambda 亚马逊云形成
上一篇:阻止AWSS3洗掉空目錄?
