【问题标题】:Cannot find any resources in SAM template在 SAM 模板中找不到任何资源
【发布时间】:2022-01-18 20:13:01
【问题描述】:

我在 JetBrains Rider 上编写了一个 lambda aws 函数,在尝试部署 template.yaml 文件时,我收到一个 aws 工具错误的内容

在 SAM 模板 project_path/template.yaml 中找不到任何资源

.yaml 文件内容:

Transform: AWS::Serverless-2016-10-31
Description: >
  Sample SAM Template for lambda
Globals:
  Function:
    Timeout: 900
    
    
Metadata:
  AWS::ServerlessRepo::Application:
    Name: report_serverless
    Description: report_serverless
    Author: user
    
Resources:
  ReportServerlessFunction:
    Type: AWS::Serverless::Function  
    Properties:
      CodeUri: ./data/
      Handler: report_serverless::report_serverless.Function::FunctionHandler
      Runtime: dotnetcore3.1
      Architectures:
        - x86_64
      Environment: 
        Variables:
          VaultApiHost: *******
          VaultApiToken: *******
          VaultCertificate: ****
          ASPNETCORE_ENVIRONMENT: Development
          
      VpcConfig:
        SecurityGroupIds:
          - *******
        SubnetIds:
          - *********
          - *********
          - *********

      FileSystemConfigs:
        - Arn: !GetAtt AccessPoint.Arn 
          LocalMountPath: /mnt/efs
          
      Events:
        ReportServerless:
          Type: Api 
          Properties:
            Path: /report
            Method: get
      Policies:
        - Statement:
            - Sid: AWSLambdaVPCAccessExecutionRole
              Effect: Allow
              Action:
                - logs:CreateLogGroup
                - logs:CreateLogStream
                - logs:PutLogEvents
                - ec2:CreateNetworkInterface
                - ec2:DescribeNetworkInterfaces
                - ec2:DeleteNetworkInterface
              Resource: "*"
            - Sid: AmazonElasticFileSystemClientFullAccess
              Effect: Allow
              Action:
                - elasticfilesystem:ClientMount
                - elasticfilesystem:ClientRootAccess
                - elasticfilesystem:ClientWrite
                - elasticfilesystem:DescribeMountTargets
              Resource: "*"
  MyMountTarget:
    Type: AWS::EFS::MountTarget
    Properties:
      FileSystemId: *********
      SecurityGroups:
        - *********
      SubnetId: ********
      
  AccessPoint:
    Type: AWS::EFS::AccessPoint
    Properties:
      FileSystemId: ***********

Outputs:
  ReportServerlessApi:
    Description: "API Gateway endpoint URL for Prod stage for Report Serverless function"
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
  ReportServerlessFunction:
    Description: "Report Serverless Lambda Function ARN"
    Value: !GetAtt ReportServerlessFunction.Arn
  ReportServerlessFunctionIamRole:
    Description: "Implicit IAM Role created for Report Serverless function"
    Value: !GetAtt ReportServerlessRole.Arn

并尝试从控制台部署返回

错误:无法为堆栈创建变更集:sam-app,例如:Waiter ChangeSetCreateComplete 失败:Waiter 遇到终端故障状态:对于表达式“状态”,我们匹配预期路径:“失败”状态:失败。原因:T 模板错误:Fn::GetAtt 的实例引用了未定义的资源 ReportServerlessRole

使用 Sam 验证代码回复文件有效,并创建 ReportServerlessRole.Arn

【问题讨论】:

    标签: c# aws-lambda yaml jetbrains-rider


    【解决方案1】:

    可能是复制/粘贴问题,但您的模板是否在最顶部缺少一行?

    AWSTemplateFormatVersion: '2010-09-09'
    

    【讨论】:

    • 很遗憾这是一个复制/粘贴问题,但感谢您的建议
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-28
    • 1970-01-01
    • 1970-01-01
    • 2012-08-14
    • 1970-01-01
    • 1970-01-01
    • 2023-01-24
    相关资源
    最近更新 更多