首页 > 解决方案 > AWS SAM 部署错误 - 验证错误 | CreateChangeSet 操作错误

问题描述

尝试使用sam deploy --guided我的 lambda 应用程序时出现以下错误。

错误:无法为堆栈创建变更集:{stack-name},调用 CreateChangeSet 操作时发生错误 (ValidationError):Stack:arn:aws:cloudformation:ap-southeast-2:014009325916:stack/{stack-name }/f2212bf0-bb41-11ea-8ef3-0aa7af0536b6 处于 ROLLBACK_COMPLETE 状态,无法更新。

这个问题的一些进一步背景是我所有的 lambda 函数都可以not have authorization defined。不确定这是否相关,但我会在它的情况下说明它。

坦率地说,我不知道如何解决这个问题。任何帮助表示赞赏。

===

背景: 构建自动交易系统

请求 Cloudformation 模板:

yaml

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: A tradingview alert wrapper that interprets alerts and makes trades according to them.

Globals:
    Function:
        # CodeUri: function/.
        # Runtime: python3.8
        # Policies:
        #     - AWSLambdaFullAccess
        # Tracing: Active
        # Timeout: 30
        Environment:
            Variables:
                APIKEY: ""
                SECRETKEY: ""


Resources:
    tradeFunction:
        Type: AWS::Serverless::Function
        Properties:
            Handler: app.trade
            Description: The primary execution function
            CodeUri: function/.
            Runtime: python3.8
            Policies:
                - AWSLambdaFullAccess
            Tracing: Active
            Timeout: 60
            Events:
                inputResponse:
                    Type: Api
                    Auth:
                        ApiKeyRequired: false
                        Authorizer: NONE
                    Properties:
                        Path: /trade
                        Method: post
                        

    printAccountBalanceFunction:
        Type: AWS::Serverless::Function
        Properties:
            CodeUri: function/.
            Runtime: python3.8
            Policies:
                - AWSLambdaFullAccess
            Tracing: Active
            Timeout: 30
            Handler: app.print_account_balance
            Description: Returns account balance over time or trade
            Events:
                inputResponse:
                    Type: Api
                    Properties:
                        Path: /print_account_balance
                        Method: get
    startTradesFunction:
        Type: AWS::Serverless::Function
        Properties:
            CodeUri: function/.
            Runtime: python3.8
            Policies:
                - AWSLambdaFullAccess
            Tracing: Active
            Timeout: 30
            Handler: app.start_trades
            Description: Resets trade log for a fresh start
            Events:
                inputResponse:
                    Type: Api
                    Properties:
                        Path: /start_trades
                        Method: get                   
    retrieveTradeLogFunction:
        Type: AWS::Serverless::Function
        Properties:
            CodeUri: function/.
            Runtime: python3.8
            Policies:
                - AWSLambdaFullAccess
            Tracing: Active
            Timeout: 30
            Handler: app.retrieve_trade_log
            Description: Return all the trade logs in the dyanamoDB database
            Events:
                inputResponse:
                    Type: Api
                    Properties:
                        Path: /retrieve_trade_log
                        Method: get



标签: amazon-web-servicesaws-lambda

解决方案


据我了解,当一个人进行初始部署并且初始部署失败时会遇到该错误。结果,出现了一些问题,部署服务无法成功执行。要解决此问题,只需删除aws cloudformation stack并重新部署即可。

可以使用以下命令删除:

aws cloudformation delete-stack --stack-name <insert stack-name>

参考


推荐阅读