Skip to content
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

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

Open
kirill-andr opened this issue Sep 5, 2024 · 2 comments
Labels
area/validate sam validate command type/feature Feature request

Comments

@kirill-andr
Copy link

kirill-andr commented Sep 5, 2024

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 kirill-andr added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Sep 5, 2024
@hnnasit
Copy link
Contributor

hnnasit commented Sep 11, 2024

Hi @kirill-andr, thanks for opening the issue. Do you have a link to the previous discussion you mentioned? Let me check with the team what's the right behavior here.

@hnnasit hnnasit added area/validate sam validate command and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Sep 11, 2024
@lucashuy
Copy link
Contributor

Hi, using Auth with DefinitionUri is an existing limitation, as the template would need to be fully transformed before Cloudformation can utilize the authorizers. This is apart of the reason why DefinitionBody is recommended, however in the context of sam validate, SAM CLI does not currently resolve the transform intrinsic locally.

When using DefinitionBody, you can use sam validate --lint to validate the rest of the template contents, but this will not validate the API definition file contents.

I can mark this as a feature request in the mean time.

@lucashuy lucashuy added the type/feature Feature request label Sep 12, 2024
@lucashuy lucashuy changed the title Bug: TITLE Feature request: Resolve AWS::Include transform intrinsic for DefinitionBody in validate Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/validate sam validate command type/feature Feature request
Projects
None yet
Development

No branches or pull requests

3 participants