examples icon indicating copy to clipboard operation
examples copied to clipboard

API Gateway sage maker end point

Open vikramranabhatt opened this issue 2 years ago • 0 comments

I want to create API Gateway for Sagemaker end point using serverless.yam. Its failing .

An error occurred: ApiGatewayMethod - Role ARN must be specified for AWS integrations (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: cb987b30-1ea1-4877-b6b9-e2817d7462b3; Proxy: null).

looks like my template is wrong...could any one help me with api gateway example

serverless.yaml

> ApiGatewayRestApi:
  Type: AWS::ApiGateway::RestApi
  Properties:
    ApiKeySourceType: HEADER
    Description: An API Gateway with a sagemaker Integration
    EndpointConfiguration:
      Types:
        - EDGE
    Name: Rsage-api

ApiGatewayResource:
  Type: AWS::ApiGateway::Resource
  Properties:
    ParentId: !GetAtt ApiGatewayRestApi.RootResourceId
    PathPart: 'sagemaker'
    RestApiId: !Ref ApiGatewayRestApi

ApiGatewayMethod:
  Type: AWS::ApiGateway::Method
  Properties:
    ApiKeyRequired: false
    AuthorizationType: NONE
    HttpMethod: POST
    Integration:
      ConnectionType: INTERNET
      #Credentials: !GetAtt ApiGatewayIamRole.Arn
      IntegrationHttpMethod: POST
      PassthroughBehavior: WHEN_NO_MATCH
      TimeoutInMillis: 29000
      Type: AWS
      Uri: !Sub "arn:aws:apigateway:${self:provider.region}:runtime.sagemaker:path/endpoints/xgboost-2022-03-08-08-31-11-865/invocations"
    OperationName: 'lambda'
    ResourceId: !Ref ApiGatewayResource
    RestApiId: !Ref ApiGatewayRestApi

ApiGatewayModel:
  Type: AWS::ApiGateway::Model
  Properties:
    ContentType: 'application/json'
    RestApiId: !Ref ApiGatewayRestApi
    Schema: { }

ApiGatewayStage:
  Type: AWS::ApiGateway::Stage
  Properties:
    DeploymentId: !Ref ApiGatewayDeployment
    Description: Lambda API Stage v0
    RestApiId: !Ref ApiGatewayRestApi
    StageName: 'v0'

ApiGatewayDeployment:
  Type: AWS::ApiGateway::Deployment
  DependsOn: ApiGatewayMethod
  Properties:
    Description: RSage API Deployment

vikramranabhatt avatar Mar 14 '22 17:03 vikramranabhatt