aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

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

Open kirill-andr opened this issue 5 months ago • 2 comments

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"
  ]
}

kirill-andr avatar Sep 05 '24 08:09 kirill-andr