gpt4 book ai didi

amazon-web-services - 错误 : Failed to create/update the stack: resume-stack, 服务员 StackUpdateComplete 失败

转载 作者:行者123 更新时间:2023-12-03 07:16:24 33 4
gpt4 key购买 nike

我正在尝试逐步重现此视频中的说明“安装 AWS SAM CLI 并创建 S3 存储桶”(来自 youtube,https://www.youtube.com/watch?v=EeLdSO6LHW0m) ,了解如何使用 SAM 作为基础设施即代码来创建 S3 存储桶。

我已按照视频的说明一步一步进行操作;但是,当我运行 aws-vault 命令来创建 S3 存储桶时,我收到以下错误消息:

% aws-vault exec my-user --no-session -- sam deploy         
File with same data already exists at resume-stack/445f94158914d32693176a0725a98472, skipping upload

Deploying with following values
===============================
Stack name : resume-stack
Region : us-east-1
Confirm changeset : False
Disable rollback : False
Deployment s3 bucket : aws-sam-cli-managed-default-samclisourcebucket-rzqvgcwwyja9
Capabilities : ["CAPABILITY_IAM"]
Parameter overrides : {}
Signing Profiles : {}

Initiating deployment
=====================
Uploading to resume-stack/e89cc5a3136547707b1bcb1032c2d3b0.template 1350 / 1350 (100.00%)

Waiting for changeset to be created..
CloudFormation stack changeset
-----------------------------------------------------------------------------------------------------------------------------------------------------
Operation LogicalResourceId ResourceType Replacement
-----------------------------------------------------------------------------------------------------------------------------------------------------
+ Add MyWebsite AWS::S3::Bucket N/A
-----------------------------------------------------------------------------------------------------------------------------------------------------

Changeset created successfully. arn:aws:cloudformation:us-east-1:053806060854:changeSet/samcli-deploy1671330287/7674b5d9-9fb6-4187-8208-150664530af4


2022-12-17 21:25:00 - Waiting for stack create/update to complete

CloudFormation events from stack operations (refresh every 0.5 seconds)
-----------------------------------------------------------------------------------------------------------------------------------------------------
ResourceStatus ResourceType LogicalResourceId ResourceStatusReason
-----------------------------------------------------------------------------------------------------------------------------------------------------
CREATE_IN_PROGRESS AWS::S3::Bucket MyWebsite -
CREATE_FAILED AWS::S3::Bucket MyWebsite my-resume-website already exists
UPDATE_ROLLBACK_IN_PROGRESS AWS::CloudFormation::Stack resume-stack The following resource(s) failed to
create: [MyWebsite].
UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN AWS::CloudFormation::Stack resume-stack -
_PROGRESS
DELETE_COMPLETE AWS::S3::Bucket MyWebsite -
UPDATE_ROLLBACK_COMPLETE AWS::CloudFormation::Stack resume-stack -
-----------------------------------------------------------------------------------------------------------------------------------------------------
Error: Failed to create/update the stack: resume-stack, Waiter StackUpdateComplete failed: Waiter encountered a terminal failure state: For expression "Stacks[].StackStatus" we matched expected path: "UPDATE_ROLLBACK_COMPLETE" at least once

我的 IAM 用户拥有以下权限:

  • AmazonAPIGateway管理员
  • IAM完全访问
  • AmazonS3FullAccess
  • AWSCloudFormationFullAccess
  • AWSLambda_FullAccess
  • AWSIQFullAccess

我的 template.yaml 文件:

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

Sample SAM Template for cloud-resume

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

Resources:
MyWebsite:
Type: AWS::S3::Bucket
Properties:
BucketName: my-resume-website
HelloWorldFunction:
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:
CodeUri: hello_world/
Handler: app.lambda_handler
Runtime: python3.9
Architectures:
- x86_64
Events:
HelloWorld:
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: /hello
Method: get

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
HelloWorldApi:
Description: "API Gateway endpoint URL for Prod stage for Hello World function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
HelloWorldFunction:
Description: "Hello World Lambda Function ARN"
Value: !GetAtt HelloWorldFunction.Arn
HelloWorldFunctionIamRole:
Description: "Implicit IAM Role created for Hello World function"
Value: !GetAtt HelloWorldFunctionRole.Arn

我已经删除了 CloudFormation 中的堆栈以及运行 sam deploy 后创建的所有 S3 存储桶,并在 template.yaml 文件中使用不同的堆栈名称和 s3 存储桶名称重新运行 sam deploy,但我仍然收到相同的错误消息。

我还尝试更改 template.yaml 文件中的资源代码块,如上一个问题所述:AWS Sam: Failed to create/update the stack Error

我更改了 template.yaml 文件中的节:

Resources:
MyWebsite:
Type: AWS::S3::Bucket
Properties:
BucketName: my-resume-website

上述 stackoverflow 问题中推荐的格式:

Parameters:
MyBucketName:
Type: String
Default: "resume-website"

Resources:
PatientCheckoutBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub "prefix-${MyBucketName}-suffix"

这有效,并且成功添加了 S3 存储桶,但将该存储桶命名为“prefix-resume-website-suffix”。

当我从 BucketName 中删除“prefix-”和“-suffix”时,sam 部署再次失败。

如何将 s3 存储桶添加为“简历网站”而不使用“前缀-”和“-后缀”?

我真诚地感谢任何人对此提供的帮助。

最好,

贾斯汀

最佳答案

AWS 上的某些资源需要是全局唯一的(例如 s3 存储桶名称),即在 AWS 上的其他任何地方都不会使用,而有些资源需要仅在您的 AWS 账户和特定区域内是唯一的(例如 lambda 和 SQS 名称)

我怀疑您遇到了先前已使用的存储桶名称的问题,我建议采用简单的命名约定,以避免所有资源上的命名冲突(特别是对于拥有多个开发人员的公司内的生产资源,以避免命名冲突,并且为了一目了然地看到哪些资源属于哪些堆栈),可以在资源名称前添加您的堆栈名称,例如:

Resources:
# s3 Buckets
MyResumeWebsite:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub ${AWS::StackName}-my-resume-website

# lambdas
SomeLambda:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub ${AWS::StackName}-SomeLambda

# SQSs
SomeSQS:
Type: AWS::SQS::Queue
Properties:
QueueName: !Sub ${AWS::StackName}-SomeSQS

关于amazon-web-services - 错误 : Failed to create/update the stack: resume-stack, 服务员 StackUpdateComplete 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74842403/

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