【发布时间】:2021-09-11 10:29:54
【问题描述】:
我正在尝试使用 AWS Sam 构建支持 S3 的测试应用程序。以下是内容。
template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
patientcheckout
Sample SAM Template for patientcheckout
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 20
Runtime: java11
MemorySize: 512
Resources:
PatientCheckoutBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: "!Sub ${AWS::StackName}-${AWS::AccountId}-${AWS::Region}"
PatientCheckoutFunction:
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: patientcheckout
Handler: com.yohan.lambda.PatientCheckoutLambda::handler
Policies:
- S3ReadPolicy:
BucketName: !Sub ${AWS::StackName}-${AWS::AccountId}-${AWS::Region}
Events:
S3Event:
Type: S3 # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Bucket: !Ref PatientCheckoutBucket
Events: s3:ObjectCreated:*
应用程序可以使用sam build 成功构建。在尝试部署时,我们最终会遇到此错误。
D:\pop\awslambda\patientcheckout>sam deploy --guided
Configuring SAM deploy
======================
Looking for config file [samconfig.toml] : Found
Reading default arguments : Success
Setting default arguments for 'sam deploy'
=========================================
Stack Name [patientcheckout]: patientcheckout
AWS Region [us-east-1]:
#Shows you resources changes to be deployed and require a 'Y' to initiate deploy
Confirm changes before deploy [y/N]:
#SAM needs permission to be able to create roles to connect to the resources in your template
Allow SAM CLI IAM role creation [Y/n]:
Save arguments to configuration file [Y/n]:
SAM configuration file [samconfig.toml]:
SAM configuration environment [default]:
Looking for resources needed for deployment: Found!
Managed S3 bucket: aws-sam-cli-managed-default-samclisourcebucket-1hmnzbuee9816
A different default S3 bucket can be set in samconfig.toml
Saved arguments to config file
Running 'sam deploy' for future deployments will use the parameters saved above.
The above parameters can be changed by modifying samconfig.toml
Learn more about samconfig.toml syntax at
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html
Deploying with following values
===============================
Stack name : patientcheckout
Region : us-east-1
Confirm changeset : False
Deployment s3 bucket : aws-sam-cli-managed-default-samclisourcebucket-1hmnzbuee9816
Capabilities : ["CAPABILITY_IAM"]
Parameter overrides : {}
Signing Profiles : {}
Initiating deployment
=====================
Waiting for changeset to be created..
CloudFormation stack changeset
---------------------------------------------------------------------------------------------------------------------
Operation LogicalResourceId ResourceType Replacement
---------------------------------------------------------------------------------------------------------------------
+ Add PatientCheckoutBucket AWS::S3::Bucket N/A
+ Add PatientCheckoutFunctionRole AWS::IAM::Role N/A
+ Add PatientCheckoutFunctionS3Ev AWS::Lambda::Permission N/A
entPermission
+ Add PatientCheckoutFunction AWS::Lambda::Function N/A
---------------------------------------------------------------------------------------------------------------------
Changeset created successfully. arn:aws:cloudformation:us-east-1:716460586643:changeSet/samcli-deploy1624953681/834f8797-6047-4d72-b368-9d54ea9783ac
2021-06-29 13:31:31 - Waiting for stack create/update to complete
CloudFormation events from changeset
---------------------------------------------------------------------------------------------------------------------
ResourceStatus ResourceType LogicalResourceId ResourceStatusReason
---------------------------------------------------------------------------------------------------------------------
CREATE_IN_PROGRESS AWS::IAM::Role PatientCheckoutFunctionRole Resource creation Initiated
CREATE_IN_PROGRESS AWS::IAM::Role PatientCheckoutFunctionRole -
CREATE_COMPLETE AWS::IAM::Role PatientCheckoutFunctionRole -
CREATE_IN_PROGRESS AWS::Lambda::Function PatientCheckoutFunction -
CREATE_COMPLETE AWS::Lambda::Function PatientCheckoutFunction -
CREATE_IN_PROGRESS AWS::Lambda::Function PatientCheckoutFunction Resource creation Initiated
CREATE_IN_PROGRESS AWS::Lambda::Permission PatientCheckoutFunctionS3Ev -
entPermission
CREATE_IN_PROGRESS AWS::Lambda::Permission PatientCheckoutFunctionS3Ev Resource creation Initiated
entPermission
CREATE_COMPLETE AWS::Lambda::Permission PatientCheckoutFunctionS3Ev -
entPermission
ROLLBACK_IN_PROGRESS AWS::CloudFormation::Stack patientcheckout The following resource(s)
failed to create:
[PatientCheckoutBucket].
Rollback requested by user.
CREATE_FAILED AWS::S3::Bucket PatientCheckoutBucket Bad Request (Service:
Amazon S3; Status Code:
400; Error Code: 400 Bad
Request; Request ID:
7NRVBFEJSMBTGM0G; S3
Extended Request ID: 9tGgby
nxYIq05EvkwIF8KZgbQNoGEOfkI
Hsl+DoKYcGSyh1Ti4Et/pVZG/uS
0LfgFR+WYyZV++k=; Proxy:
null)
CREATE_IN_PROGRESS AWS::S3::Bucket PatientCheckoutBucket -
DELETE_COMPLETE AWS::S3::Bucket PatientCheckoutBucket -
DELETE_IN_PROGRESS AWS::Lambda::Permission PatientCheckoutFunctionS3Ev -
entPermission
DELETE_IN_PROGRESS AWS::Lambda::Function PatientCheckoutFunction -
DELETE_COMPLETE AWS::Lambda::Permission PatientCheckoutFunctionS3Ev -
entPermission
DELETE_COMPLETE AWS::Lambda::Function PatientCheckoutFunction -
DELETE_IN_PROGRESS AWS::IAM::Role PatientCheckoutFunctionRole -
ROLLBACK_COMPLETE AWS::CloudFormation::Stack patientcheckout -
DELETE_COMPLETE AWS::IAM::Role PatientCheckoutFunctionRole -
---------------------------------------------------------------------------------------------------------------------
Error: Failed to create/update the stack: patientcheckout, Waiter StackCreateComplete failed: Waiter encountered a terminal failure state: For expression "Stacks[].StackStatus" we matched expected path: "ROLLBACK_COMPLETE" at least once
我该如何解决这个问题?
【问题讨论】:
标签: java amazon-web-services amazon-s3 aws-sam