Reputation: 1
I wrote a lambda aws function on JetBrains Rider, and while trying to get to deploy the template.yaml file i get an aws tools error with the content
Cannot find any resources in SAM template project_path/template.yaml
.yaml file content:
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
and trying to deploy from console returns
Error: Failed to create changeset for the stack: sam-app, ex: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state: For expression "Status" we matched expected path: "FAILED" Status: FAILED. Reason: T emplate error: instance of Fn::GetAtt references undefined resource ReportServerlessRole
using the Sam validate code replies the file is valid, and also ReportServerlessRole.Arn is created
Upvotes: 0
Views: 902
Reputation: 61
I was getting the same error because template.yaml
was inside a directory which I previously marked as Excluded
in PyCharm. This directory wasn't indexed and for some reason that caused deployment failures.
The solution was to Cancel Exclusion (right click on a directory containing template.yaml
-> Mark Directory as -> Cancel Exclusion). That triggered the indexing and after that I was able to deploy.
Note:
The directory can be marked as Excluded
again and the deployment will still work. But this is probably not the best idea because deployment would rely on the previously generated indexes which might be outdated if directory content has changed. Additionally, exclusion would have to be canceled each time the indexes are cleared (e.g. PyCharm cache invalidation).
Upvotes: 0
Reputation: 2038
Perhaps a copy/ paste issue, but is your template missing a line at the very top?
AWSTemplateFormatVersion: '2010-09-09'
Upvotes: 0