2

I want to control access to my api gateway fronting lambda with iam permissions: https://docs.aws.amazon.com/apigateway/latest/developerguide/permissions.html

I have seen no examples of how to configure this in a sam template. What does a sam template look like that has authorizationType property set to AWS_IAM?

I think I read somewhere that Sam doesn't support this directly but you can do it with swagger? Can I use swagger to get around this limitation? I haven't found a simple example of that.

red888
  • 27,709
  • 55
  • 204
  • 392

2 Answers2

0

The SAM template for AWS::Serverless::Api does not provide the authorizationType. You could instead use the AWS::ApiGateway::Method in your SAM template, but that means you have to define your API Gateway using CloudFormation resource types rather than SAM.

hin522
  • 59
  • 2
0

You can use the DefaultAuthorizer: AWS_IAM under Auth:

Example:

Resources:
  MyApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod
      Auth:
        DefaultAuthorizer: AWS_IAM

More: IAM permission example