serverless-application-model icon indicating copy to clipboard operation
serverless-application-model copied to clipboard

AWS::Serverless::Api - Auth property doesn't allow intrinsic functionality

Open cantwelc opened this issue 5 years ago • 1 comments

The intrinsic mapping for Auth on APIs does not appear to have been added in v1.16 or v1.20.0 from what I can see. I can see intrinsic mapping for function deployment preferences was in (https://github.com/awslabs/serverless-application-model/issues/1196)

Could this please be added to the roadmap?

cantwelc avatar Mar 10 '20 08:03 cantwelc

Here are some test templates:

Works

Transform: AWS::Serverless-2016-10-31
Parameters:
  VpcParameter:
    Type: String
Resources:
  ApiGateway:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod
      EndpointConfiguration: PRIVATE
      Auth:
        ResourcePolicy:
          SourceVpcWhitelist:
            - !Ref VpcParameter
  Func:
    Type: AWS::Serverless::Function
    Properties:
      Runtime: python3.7
      InlineCode: |
        def handler(event, context):
            return {'statusCode': 200, 'body': 'OK'}
      Handler: "index.handler"
      Events:
        Whatever:
          Type: Api
          Properties:
            RestApiId: !Ref ApiGateway
            Method: GET
            Path: /

Fails

Transform: AWS::Serverless-2016-10-31
Resources:
  VpcResource:
    Type: AWS::EC2::VPC
    Properties: 
      CidrBlock: 10.0.0.0/16
  ApiGateway:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod
      EndpointConfiguration: PRIVATE
      Auth:
        ResourcePolicy:
          SourceVpcWhitelist:
            - !Ref VpcResource
  Func:
    Type: AWS::Serverless::Function
    Properties:
      Runtime: python3.7
      InlineCode: |
        def handler(event, context):
            return {'statusCode': 200, 'body': 'OK'}
      Handler: "index.handler"
      Events:
        Whatever:
          Type: Api
          Properties:
            RestApiId: !Ref ApiGateway
            Method: GET
            Path: /

We would like to use an !ImportValue for the VPC, that fails too (but doesn't fit in a single demo template)

benbridts avatar Mar 10 '20 11:03 benbridts

Closing in favor of https://github.com/aws/serverless-application-model/issues/2533.

hoffa avatar Nov 03 '22 23:11 hoffa