无法在AWS中创建/更新堆栈

时间:2018-07-06 09:08:33

标签: amazon-web-services amazon-s3 aws-sam-cli aws-serverless

我写的代码是

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

    Sample SAM Template for sam-app

Globals:
    Function:
        Timeout: 300
    Api:
        Cors:
            AllowHeaders: "'content-type, authorization'"
            AllowOrigin: "'*'"


Resources:

    HelloWorldFunction:
        Type: AWS::Serverless::Function 
        Properties:
            CodeUri: hello_world
            Handler: app.lambda_handler
            Runtime: nodejs8.10
            Environment: 
                Variables:
                    PARAM1: VALUE
            Events:
                HelloWorld:
                    Type: Api 
                    Properties:
                        Path: /hello
                        Method: get


    ApiGateway:
        Type: AWS::Serverless::Api
        Properties:
            StageName: prod
            DefinitionBody:
                swagger: "2.0"
                info:
                    title: 
                    Ref: AWS::StackName
                    description: My API that uses custom authorizer
                    version: 1.0.0
                paths:
                    /hello:
                        get:
                            consumes: application/json
                            produces: application/json

我想将此代码作为

部署到云中
aws cloudformation deploy --template-file output.yaml --stack-name stack1 --parameter-overrides EnvParameter=prod --capabilities CAPABILITY_IAM

然后说

Failed to create/update the stack. Run the following command
to fetch the list of events leading up to the failure
aws cloudformation describe-stack-events --stack-name stack1

当我注释ApiGateway代码时,它工作正常。我认为错误可能在代码的下面。

ApiGateway:
        Type: AWS::Serverless::Api
        Properties:
            StageName: prod
            DefinitionBody:
                swagger: "2.0"
                info:
                    title: something
                    Ref: AWS::StackName
                    description: My API that uses custom authorizer
                    version: 1.0.0
                paths:
                    /hello:
                        get:
                            consumes: application/json
                            produces: application/json

请帮助我解决此问题。

谢谢...

1 个答案:

答案 0 :(得分:0)

这可能已经晚了,但是导致我的cloudformation失败的问题是,我创建云形式的程序用户帐户没有iam:CreateRole权限。更新该用户的策略可解决此问题。

相关问题