"DeployApi" : {
  "Type": "AWS::ApiGateway::RestApi",
  "Properties": {
    "Name": { "Fn::Join": ["-", ["deploy", { "Ref": "AWS::StackName" } ] ] }
  }
},
"DeployResource" : {
  "Type" : "AWS::ApiGateway::Resource",
  "DependsOn": [ "DeployApi" ],
  "Properties" : {
    "ParentId" : { "Fn::GetAtt": ["DeployApi", "RootResourceId"] },
    "PathPart" : { "Ref": "DeployKeyPath" },
    "RestApiId" : { "Ref": "DeployApi" }
  }
},
"DeployPOST": {
  "Type" : "AWS::ApiGateway::Method",
  "DependsOn": [ "DeployLambda" ],
  "Properties" : {
    "HttpMethod" : "POST",
    "AuthorizationType": "NONE",
    "Integration" : {
      "PassthroughBehavior": "WHEN_NO_MATCH",
      "Type": "AWS",
      "IntegrationHttpMethod" : "POST",
      "IntegrationResponses": [{
        "ResponseTemplates": { "application/json": null },
        "StatusCode": "200"
      }]
    },
    "MethodResponses" : [{ "StatusCode": "200" }],
    "ResourceId" : {"Ref": "DeployResource"},
    "RestApiId" : {"Ref": "DeployApi"},
    "Uri": { "Fn::Join": [ "", [
      "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/",
      { "Fn::GetAtt": ["DeployLambda", "Arn" ]},
      "/invocations"
    ]]}
  }
},
"DeployDeployment": {
  "DependsOn": "DeployPOST",
  "Type": "AWS::ApiGateway::Deployment",
  "Properties": {
    "RestApiId" : { "Ref": "DeployApi" },
    "StageName": "DummyStage"
  }
},
"DeployProdStage": {
  "Type" : "AWS::ApiGateway::Stage",
  "Properties" : {
    "DeploymentId" : {"Ref": "DeployDeployment"},
    "MethodSettings" : [{
      "ResourcePath": { "Fn::Join": ["", ["/", { "Ref": "DeployKeyPath" } ] ] },
      "HttpMethod": "POST",
      "ThrottlingRateLimit": 2,
      "ThrottlingBurstLimit": 4
    }],
    "RestApiId" : { "Ref": "DeployApi" },
    "StageName" : "prod"
  }
}
