-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sam validate expects DefinitionBody or DefinitionUri to be set #803
Comments
Are there any updates? Not being able to run validate and/or cfn-lint really makes automated CI/CD difficult |
please someone, work on this <3 |
Still seeing this with sam 0.16.1 please fix |
@jackmcguire1 or @rudpot Either of you want to take a stab at a fix? |
yes I have this problem too and this is annoying. Having Cognito in my template, sam validate becomes useless. |
Still have this issue, please fix it! |
Release in v0.21.0. Closing |
@jfuss 'sam validate' seems to still be broken if using Fn::Transform and AWS::Include to reference and include an OpenAPI definition in a separate file while having a Globals -> Api -> Cors config in the SAM template.
SAM template:
If I comment out my global cors config in my SAM template then validation works fine. |
@jfuss I'm also experiencing the same issue paulsson-cs is reporting. Anyway we can get this one reopened to address this? |
You need to add |
This still seems to be an issue: #1074 (comment) |
I have SAM CLI, version 1.6.2 Reopen an fix it please. |
Seems to me that this should not be closed. I'm encountering this very same error, even though my stack deploys and runs fine. Serverless APIMyApi:
Type: 'AWS::Serverless::Api'
Properties:
Name: !Sub ${ENV}-my-api
Domain:
BasePath: !Ref StageName
DomainName: !Ref CustomDomainName
CertificateArn: !If [ CreateCert, !Ref AutoGeneratedCert, !Ref CertArn ]
Route53:
HostedZoneId: !If [ CreateZone, !Ref HostedZoneId, !Ref ZoneId ]
EvaluateTargetHealth: true
IpV6: true
StageName: !Ref StageName
EndpointConfiguration: REGIONAL
DefinitionBody:
Fn::Transform:
Name: AWS::Include
Parameters:
Location: openapi.yaml
Auth:
UsagePlan:
UsagePlanName: fooUsagePlan
CreateUsagePlan: SHARED
Throttle:
BurstLimit: 1000
RateLimit: 500
Tags:
service: my-service
env: !Sub ${ENV}
Variables:
LOG_LEVEL: "99"
env: !Sub ${ENV} Result from
|
Same issue here, this is my current workaround:
|
@julianste I've moved to SAM nightlies (1.21.1) to see if it was resolved there. I tried your 3 workaround lines, but got another error. Seems it's not happy with that incomplete definition. if definition_body.get("paths").get(path).get("options"):
AttributeError: 'str' object has no attribute 'get' |
@rainabba my workaround probably just works for EDIT: Something like this seems to satisfy
|
@julianste @rainabba I have this working locally. The fix is to get the validator to detect the Transform->Include->Location pattern and replace the DefinitionBody with the contents of the yaml file itself during validation. |
The workaround of copying contents of the api definition swagger file and pasting them exactly as they are under "DefinitionBody:" works. Thank you! However, this is not a practical solution and a very error-prone one. @jfuss I do not think this ticket should be kept closed, the issue is still there. |
It worked without the definitionBody for couple of AWS SAM versions, and now it does not, possible regression ? |
@aleguern Turns out the fix for this was easy enough so I'm pushing this through again in a new PR. |
Great news thank you so much |
I see this same issue in SAM CLI version 1.61.0, it looks like the PR #3882 was never merged. Are there any plans to fix this? |
@cortexcompiler I ran out of capacity to make all the required changes that came up in the fix PR. |
problem still persists on version 1.81.0 is still beeing displayed erroneously even after passing correctly
stack still deploys and builds fine |
I am getting this error with Resources:
ApiGateway:
Type: AWS::Serverless::Api
Properties:
OpenApiVersion: 3.0.0
DefinitionBody:
'Fn::Transform':
Name: 'AWS::Include'
Parameters:
Location: 'oas3.yaml'
StageName: Prod
Auth:
ResourcePolicy:
IpRangeWhitelist:
- !Ref IPWhitelist I can use the workaround provided in #803 (comment) it would be great if this could be fixed. @NickHeap2 do you think you would have capacity sometime to re-open your previous PR #3882? No worries if not. |
Description:
Since the Default Definition Body feature, SAM provides a default DefinitionBody if neither a DefinitionBody or DefinitionUri is set on a AWS::Serverless:Api resource.
SAM CLI still expects DefinitionBody or DefinitionUri to be set in the validation workflow as found here. This assumption should be fixed (check for and replace DefinitionUri with a S3 location if it exists, otherwise do nothing).
Steps to reproduce the issue:
sam validate
on https://github.com/awslabs/serverless-application-model/blob/master/examples/2016-10-31/api_cognito_auth/template.yamlObserved result:
Expected result:
Validation should succeed
Output of
sam --version
:0.7.0, 0.8.0, 0.9.0
The text was updated successfully, but these errors were encountered: