aws / aws/aws-sam-cli

Feature request: Resolve AWS::Include transform intrinsic for DefinitionBody in validate

Open
#7,440 2 comments 0 reactions 0 assignees View on GitHub
area/validate type/feature
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Description:
Error: Auth works only with inline Swagger specified in 'DefinitionBody' property.
It seems that this has already been discussed in 2021, but it is still appearing the the latest SAM.
sam `validate` treats Auth and DefinitionUri as invalid for resource AWS::Serverless::Api.
Has this issue been solved or is it still ongoing? Seems like there were patches in place to address this.

### Steps to reproduce:
This will throw an error:
```
ApiGatewayRestApiAnalitiqBackend:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
Auth:
DefaultAuthorizer: CognitoAuthorizer
Authorizers:
CognitoAuthorizer:
UserPoolArn: !Ref CognitoUserPoolArn
IdentitySource: method.request.header.Authorization
DefinitionUri: 'api-slack.yaml'
```
This will not:
```
ApiGatewayRestApiAnalitiqBackend:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
Auth:
DefaultAuthorizer: CognitoAuthorizer
Authorizers:
CognitoAuthorizer:
UserPoolArn: !Ref CognitoUserPoolArn
IdentitySource: method.request.header.Authorization
DefinitionBody:
'Fn::Transform':
Name: 'AWS::Include'
Parameters:
Location:
```

### Observed result:
sam `validate `warns:

```"Auth works only with inline Swagger specified in 'DefinitionBody' property."```

### Expected result:
SAM should validate the template with API definition included as DefinitionUri as well as DefinitionBody. Especially if both refer to local file.

### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

1. OS: iOS Sonoma
2. `sam --version`: 1.12.0
3. AWS region: eu-central-1

```
# Paste the output of `sam --info` here
```
```
{
"version": "1.123.0",
"system": {
"python": "3.12.5",
"os": "macOS-14.6.1-arm64-arm-64bit"
},
"additional_dependencies": {
"docker_engine": "Not available",
"aws_cdk": "Not available",
"terraform": "Not available"
},
"available_beta_feature_env_vars": [
"SAM_CLI_BETA_FEATURES",
"SAM_CLI_BETA_BUILD_PERFORMANCE",
"SAM_CLI_BETA_TERRAFORM_SUPPORT",
"SAM_CLI_BETA_RUST_CARGO_LAMBDA"
]
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.