Jishnu Anand
Jishnu Anand

Reputation: 1

How can i create a aws sam yaml file to take in an api template through a swagger file present locally to update an existing api on api gateway?

I deployed an api on api gateway using sam and now i would like to update it using sam with the api template in a swagger file. I have permission to make changes on the api i want to but not for other apis.It gives me tells me that i am not authorized to perform apigateway:PUT on my api resource.

This is my sam yaml file. Here AppHttpApi and AppHttpApiprodStage are resources on my cloudFormation stack. Why does it say i need apigateway:PUT authorization when i need to update the api?

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: >
  SAM template to deploy or update User API on API Gateway using HTTP API and a Swagger file.

Parameters:
  Region:
    Type: String
    Default: "ap-northeast-1"
    Description: "AWS Region"
  ProdAlias:
    Type: String
    Default: "Production"
    Description: "Production alias"

Resources:
  AppHttpApi:
    Type: 'AWS::Serverless::HttpApi'
    Properties:
    DisableDefaultEndpoint: true
      DefinitionBody:
        Fn::Transform:
          Name: 'AWS::Include'
          Parameters:
            Location: swagger.yaml

  AppHttpApiprodStage:
    Type: AWS::ApiGatewayV2::Stage
    Properties:
      ApiId: !Ref AppHttpApi
      StageName: prod
      AutoDeploy: true
      Description: "Production stage for HTTP API"
      DefaultRouteSettings:
        LoggingLevel: INFO
      StageVariables:
        alias: !Ref ProdAlias

Outputs:
  ApiId:
    Description: "The ID of the HTTP API Gateway API"
    Value: !Ref AppHttpApi
  ApiEndpointDev:
    Description: "The URL of the development API Gateway endpoint"
    Value: !Sub "https://${AppHttpApi}.execute-api.${Region}.amazonaws.com/dev"
  ApiEndpointProd:
    Description: "The URL of the production API Gateway endpoint"
    Value: !Sub "https://${AppzHttpApi}.execute-api.${Region}.amazonaws.com/prod"

Upvotes: 0

Views: 52

Answers (0)

Related Questions