Cloudformation apigateway

0

I am struggling to create the code for an apigatewayv2 with the stages acceptatie, test and deployment that lead to 3 different ec2 instances with the port 8080

this is the code i have.

#API
  MyAPI:
    Type: AWS::ApiGatewayV2::Api
    Properties:
      Name: MyAPI
      ProtocolType: HTTP
  #stages
  TestStage:
    Type: AWS::ApiGatewayV2::Stage
    Properties:
      StageName: test
      ApiId: !Ref MyAPI
      DefaultRouteSettings:
        DataTraceEnabled: true
        ThrottlingBurstLimit: 500
        ThrottlingRateLimit: 10.0
      DeploymentId: !Ref TestDeployment
      StageVariables:
        TargetURL: http://ec2-test-instance.example.com

  AcceptStage:
    Type: AWS::ApiGatewayV2::Stage
    Properties:
      StageName: accept
      ApiId: !Ref MyAPI
      DefaultRouteSettings:
        DataTraceEnabled: true
        ThrottlingBurstLimit: 500
        ThrottlingRateLimit: 10.0
      DeploymentId: !Ref AcceptDeployment
      StageVariables:
        TargetURL: http://ec2-accept-instance.example.com
  
  ProductionStage:
    Type: AWS::ApiGatewayV2::Stage
    Properties:
      StageName: production
      ApiId: !Ref MyAPI
      DefaultRouteSettings:
        DataTraceEnabled: true
        ThrottlingBurstLimit: 500
        ThrottlingRateLimit: 10.0
      DeploymentId: !Ref ProductionDeployment
      StageVariables:
        TargetURL: http://ec2-production-instance.example.com

  #deployments
  TestDeployment:
    Type: AWS::ApiGatewayV2::Deployment
    Properties:
      Description: Test deployment
      ApiId: !Ref MyAPI
  
  AcceptDeployment:
    Type: AWS::ApiGatewayV2::Deployment
    Properties:
      Description: Accept deployment
      ApiId: !Ref MyAPI
  
  ProductionDeployment:
    Type: AWS::ApiGatewayV2::Deployment
    Properties:
      Description: Production deployment
      ApiId: !Ref MyAPI
 
  #routes
  TestRoute:
    Type: AWS::ApiGatewayV2::Route
    Properties:
      ApiId: !Ref MyAPI
      RouteKey: 'ANY /test'
      Target: 'integrations/TestIntegration'

  AcceptRoute:
    Type: AWS::ApiGatewayV2::Route
    Properties:
      ApiId: !Ref MyAPI
      RouteKey: 'ANY /accept'
      Target: 'integrations/AcceptIntegration'

  ProductionRoute:
    Type: AWS::ApiGatewayV2::Route
    Properties:
      ApiId: !Ref MyAPI
      RouteKey: 'ANY /production'
      Target: 'integrations/ProductionIntegration'
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions