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 Answers2

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

Suraj Bhatia
  • 1,233
  • 3
  • 13
  • 29
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.
Harish KM
  • 1,303
  • 7
  • 17
  • 1
    When linking to your own site or content (or content that you are affiliated with), you [must disclose your affiliation _in the answer_](/help/promotion) 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. – Sabito stands with Ukraine Nov 13 '20 at 08:25
  • Thanks, @Yatin. I've edited the answer to disclose my affiliation with the links in my answer. – Harish KM Jan 15 '21 at 11:58