gpt4 book ai didi

python - sam 部署失败并出现错误 存储桶位于此区域 : us-east-2. 请使用此区域到 us-east-2

转载 作者:行者123 更新时间:2023-12-03 07:19:58 27 4
gpt4 key购买 nike

我是山姆的新手。

我正在运行 aws-cli/2.1.37 Python/3.8.8 Darwin/19.6.0 exe/x86_64提示/关闭

SAM CLI,版本 1.29.0

请参阅下面的 template.yaml 文件

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
Trikle

Sample SAM Template for Trikle

# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 60

Resources:
PutProfileFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
FunctionName: PutProfile
Description: Created With SAM Framework adds users profiles
Role: arn:aws:iam::630589988206:role/lambdaAllQueryExecutionAllAccessRole
CodeUri: src/
Handler: add_profile.lambda_handler
Runtime: python3.7
Events:
PutProfile:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /PutProfile
Method: post

Outputs:
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
# Find out more about other implicit resources you can reference within SAM
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
PutProfileApi:
Description: "API Gateway endpoint URL for Prod stage for PutProfile function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/dev/PutProfile/"
PutProfileFunction:
Description: "Created With SAM Framework adds users profiles Lambda Function ARN"
Value: !GetAtt PutProfileFunction.Arn

尝试使用 SAM 将 lambda 函数和 API 网关部署到云形成框架首先,我运行命令“sam package”,项目已成功部署到我的 s3 存储桶中。但运行“sam deploy”后失败。它失败并显示错误存储桶位于此区域:us-east-2。请使用该区域到 us-east-2

发出命令 sam deploy --template-file deploy.yaml --stack-name myStack4 后查看以下错误的完整堆栈跟踪

        Deploying with following values
===============================
Stack name : mikeStack4
Region : None
Confirm changeset : False
Deployment s3 bucket : None
Capabilities : null
Parameter overrides : {}
Signing Profiles : {}

Initiating deployment
=====================

Waiting for changeset to be created..

CloudFormation stack changeset
-------------------------------------------------------------------------------------------------------------------------
Operation LogicalResourceId ResourceType Replacement
-------------------------------------------------------------------------------------------------------------------------
+ Add PutProfileFunctionPutProfile AWS::Lambda::Permission N/A
PermissionProd
+ Add PutProfileFunction AWS::Lambda::Function N/A
+ Add ServerlessRestApiDeployment7 AWS::ApiGateway::Deployment N/A
5e148f6d0
+ Add ServerlessRestApiProdStage AWS::ApiGateway::Stage N/A
+ Add ServerlessRestApi AWS::ApiGateway::RestApi N/A
-------------------------------------------------------------------------------------------------------------------------

Changeset created successfully. arn:aws:cloudformation:us-west-2:630589988206:changeSet/samcli-deploy1630606751/c1aa856f-4259-4a2d-a4cc-c6a738fb1865


2021-09-02 19:19:19 - Waiting for stack create/update to complete

CloudFormation events from changeset
-------------------------------------------------------------------------------------------------------------------------
ResourceStatus ResourceType LogicalResourceId ResourceStatusReason
-------------------------------------------------------------------------------------------------------------------------
CREATE_IN_PROGRESS AWS::Lambda::Function PutProfileFunction -
CREATE_IN_PROGRESS AWS::Lambda::Function PutProfileFunction Resource creation Initiated
ROLLBACK_IN_PROGRESS AWS::CloudFormation::Stack mikeStack4 The following resource(s)
failed to create:
[PutProfileFunction].
Rollback requested by user.
CREATE_FAILED AWS::Lambda::Function PutProfileFunction Resource handler returned
message: "Error occurred
while GetObject. S3 Error
Code: PermanentRedirect. S3
Error Message: The bucket is
in this region: us-east-2.
Please use this region to
retry the request (Service:
Lambda, Status Code: 400,
Request ID: 9edeeae4-ecd4-4d
58-baec-7bef421657e3,
Extended Request ID: null)"
(RequestToken: 1238ab0d-1fc9
-4f8f-9965-4f41d71e5804,
HandlerErrorCode:
InvalidRequest)
DELETE_IN_PROGRESS AWS::Lambda::Function PutProfileFunction -
ROLLBACK_COMPLETE AWS::CloudFormation::Stack mikeStack4 -
DELETE_COMPLETE AWS::Lambda::Function PutProfileFunction -
-------------------------------------------------------------------------------------------------------------------------
Error: Failed to create/update the stack: mikeStack4, Waiter StackCreateComplete failed: Waiter encountered a terminal failure state: For expression "Stacks[].StackStatus" we matched expected path: "ROLLBACK_COMPLETE" at least once

最佳答案

问题出在我的 AWS CLI 配置中的区域

我运行了命令 AWS configure 并将区域重置为建议的区域

部署成功

关于python - sam 部署失败并出现错误 存储桶位于此区域 : us-east-2. 请使用此区域到 us-east-2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69035744/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com