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

AWS Gateway : OpenAPI v3 YAML sample for deployment #64

Open
axel3rd opened this issue Feb 23, 2021 · 0 comments
Open

AWS Gateway : OpenAPI v3 YAML sample for deployment #64

axel3rd opened this issue Feb 23, 2021 · 0 comments

Comments

@axel3rd
Copy link
Contributor

axel3rd commented Feb 23, 2021

In part of #61, I tried to add an OpenAPI v3 AWS Gateway REST API deployment (aka: Manual AWS Lambda + API deployment).

The most simple looks file:

openapi: "3.0.1"
info:
  title: "my-probot"
  description: "API endpoint for my Probot hosted on Lambda"
  version: "1.0"
paths:
  /api/github/webhooks:
    post:
      x-amazon-apigateway-integration:
        type: "aws_proxy"
        httpMethod: "POST"
        # URI of Lambda (should end by /invocations)
        # Replace: xxx-region-xxx (x2), xxx-account-xxx, xxx-lambda-name-xxx
        # The ARN (the suffix of URI) can be retrieved from top right of your Lambda AWS console)
        uri: "arn:aws:apigateway:xxx-region-xxx:lambda:path/2015-03-31/functions/arn:aws:lambda:xxx-region-xxx:xxx-account-xxx:function:xxx-lambda-name-xxx/invocations"

Unfortunately, in the case, the Resource Policies of lambda is not updated to authorize API invocation (Lambda > Permission tab : Resource-based policy).

Should be like:

{
  "Version": "2012-10-17",
  "Id": "default",
  "Statement": [
    {
      "Sid": "probot-name-api-permission",
      "Effect": "Allow",
      "Principal": {
        "Service": "apigateway.amazonaws.com"
      },
      "Action": "lambda:InvokeFunction",
      "Resource": "arn:aws:lambda:xxx-region-xxx:xxx-account-xxx:function:xxx-lambda-name-xxx",
      "Condition": {
        "ArnLike": {
          "AWS:SourceArn": "arn:aws:execute-api:xxx-region-xxx:xxx-account-xxx:xxx-api-id-xxx/*/*/api/github/webhooks"
        }
      }
    }
  ]
}

No found a way to add it manually, require AWS Cli or SDK => perhaps using Serverless Framework is more sustainable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant