1

I'm new to AWS SAM deployment. I have a use case to automate the deployment using SAM AWS. Having a Rest API GW with another HTTP endpoint invocation. I searched pretty more docs but I didn't find any solution for this. Could you mind suggest me how to do this case?

Thanks in advance. Karthikeyan B

2
  • Do you have trouble creating the REST API with SAM? Or automating the deployment? Commented Jun 22, 2020 at 4:08
  • @SurajBhatia Issue on creating a Rest API having an HTTP endpoint invocation through SAM. Commented Jun 24, 2020 at 9:20

2 Answers 2

1

Sample template you can try for creating integration -

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: AWS SAM template with a HTTP integration
Resources:
  ApiGatewayApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: prod
      DefinitionBody: {
        "swagger": "2.0",
        "info": {
          "version": "1.0"
        },
        "paths": {
          "test": {
            "get": {
              "produces": [
                "application/json"
              ],
              "responses": {
                "200": {
                  "description": "200 response"
                }
              },
              "x-amazon-apigateway-integration": {
                "responses": {
                  "default": {
                    "statusCode": "200"
                  }
                },
                "credentials": "arn:aws:iam::account-id:role/role-name",
                "uri": "https://www.example.com",
                "passthroughBehavior": "when_no_match",
                "httpMethod": "GET",
                "type": "http_proxy"
              }
            }
          }
        }
    }

Deploy the template using CLI -

$ sam deploy --stack-name httpProxy -t httpProxy.yaml --capabilities CAPABILITY_IAM

Sign up to request clarification or add additional context in comments.

2 Comments

Is there a way where we can avoid using a swagger definition in 'DefinitionBody' ?
You can link to a swagger definition using DefinitionUri
0
  1. You can build a hello world SAM app in a few clicks using the AWS toolkit in VS Code as shown in my blog post here.
  2. Then, modify the generated SAM template (template.yaml) to integrate with an HTTP API instead of Lambda.
  3. Add a buildspec.yml to your codebase & build a CI/CD pipeline using AWS CodeBuild & CodePipeline as shown in my blog post here.

2 Comments

When linking to your own site or content (or content that you are affiliated with), you must disclose your affiliation in the answer in order for it not to be considered spam. Having the same text in your username as the URL or mentioning it in your profile is not considered sufficient disclosure under Stack Exchange policy.
Thanks, @Yatin. I've edited the answer to disclose my affiliation with the links in my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.