繁体   English   中英

在 AWS SAM 模板部署期间出现未解决的错误

[英]Getting Unresolved Error during AWS SAM template deployment

I want to create a lambda function and API gateway with the post method using AWS SAM templated and deploying the template using Github Pipeline.

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

  Sample SAM Template for lambda-neo4j

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

Resources:
  MyGraphFunction:
    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: "test-my-graph"
      CodeUri: my_graph/
      Handler: app.lambda_handler
      Runtime: python3.9
      Architectures:
        - x86_64
      Events:
        MyGraph:
          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: /mygraph
            Method: post
      Role: arn:aws:iam::1234567890:role/my-lambda-role-s3
      Environment:
        Variables:
          URI: Demo
          USER_NAME: Demo
          PASSWORD: Demo

Outputs:
  MyGraphApi:
    Description: "API Gateway endpoint URL for Prod stage for My Graph function"
    Value: !Ref "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/mygraph/"
  MyGraphFunction:
    Description: "MyGraph Lambda Function ARN"
    Value: !GetAtt MyGraphFunction.Arn

低于错误。

Error: Failed to create changeset for the stack: sam-lambda-neo4j, ex: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state: For expression "Status" we matched expected path: "FAILED" Status: FAILED. Reason: Unresolved resource dependencies [https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/mygraph/] in the Outputs block of the template

请帮忙,谢谢:)

您的输出使用了错误的字符串 function (Ref),请改用 Sub

Outputs:
  MyGraphApi:
    Description: "API Gateway endpoint URL for Prod stage for My Graph function"
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/mygraph/"
 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM