This repository has been archived by the owner on Dec 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from vinpereira/svc-virt-api-gateway-cfn-V3306…
…07454 Svc virt api gateway cfn v330607454
- Loading branch information
Showing
2 changed files
with
228 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
blog-assets/svcvirt-apigateway-cfn/AWS Blog Post.SVwithAPIGateway.postman_collection.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{ | ||
"info": { | ||
"_postman_id": "233e8d84-5068-4909-84f0-c0340b451606", | ||
"name": "AWS Blog Post", | ||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" | ||
}, | ||
"item": [ | ||
{ | ||
"name": "GET Method", | ||
"request": { | ||
"method": "GET", | ||
"header": [], | ||
"url": { | ||
"raw": "https://put-your-api-gateway-stage-address-here/v0/mock?method=created", | ||
"protocol": "https", | ||
"host": [ | ||
"put-your-api-gateway-stage-address-here" | ||
], | ||
"path": [ | ||
"v0", | ||
"mock" | ||
], | ||
"query": [ | ||
{ | ||
"key": "method", | ||
"value": "created" | ||
} | ||
] | ||
} | ||
}, | ||
"response": [] | ||
}, | ||
{ | ||
"name": "POST Method", | ||
"request": { | ||
"method": "POST", | ||
"header": [ | ||
{ | ||
"key": "Content-Type", | ||
"value": "application/json", | ||
"type": "text" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"raw": "{\r\n \"statusCode\": 226\r\n}" | ||
}, | ||
"url": { | ||
"raw": "https://put-your-api-gateway-stage-address-here/v0/mock", | ||
"protocol": "https", | ||
"host": [ | ||
"put-your-api-gateway-stage-address-here" | ||
], | ||
"path": [ | ||
"v0", | ||
"mock" | ||
], | ||
"query": [ | ||
{ | ||
"key": "scope", | ||
"value": "internal", | ||
"disabled": true | ||
} | ||
] | ||
} | ||
}, | ||
"response": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
|
||
Description: AWS API Gateway working as a Service Virtualization | ||
|
||
Resources: | ||
|
||
RestApi: | ||
Type: AWS::ApiGateway::RestApi | ||
Properties: | ||
ApiKeySourceType: HEADER | ||
Description: An API Gateway as Service Virtualization | ||
EndpointConfiguration: | ||
Types: | ||
- EDGE | ||
Name: mock-api | ||
|
||
Resource: | ||
Type: AWS::ApiGateway::Resource | ||
Properties: | ||
ParentId: !GetAtt RestApi.RootResourceId | ||
PathPart: 'mock' | ||
RestApiId: !Ref RestApi | ||
|
||
GetMethod: | ||
Type: AWS::ApiGateway::Method | ||
Properties: | ||
ApiKeyRequired: false | ||
AuthorizationType: NONE | ||
HttpMethod: GET | ||
RequestParameters: | ||
method.request.querystring.method: true | ||
MethodResponses: | ||
- ResponseModels: | ||
application/json: !Ref ApiGatewayModel | ||
StatusCode: 200 | ||
- ResponseModels: | ||
application/json: !Ref ApiGatewayModel | ||
StatusCode: 201 | ||
- ResponseModels: | ||
application/json: !Ref ApiGatewayModel | ||
StatusCode: 500 | ||
- ResponseModels: | ||
application/json: !Ref ApiGatewayModel | ||
StatusCode: 503 | ||
Integration: | ||
ConnectionType: INTERNET | ||
IntegrationResponses: | ||
- ResponseTemplates: | ||
application/json: | | ||
{ | ||
"statusCode": 200, | ||
"message": "OK. No problem here." | ||
} | ||
StatusCode: 200 | ||
- ResponseTemplates: | ||
application/json: | | ||
{ | ||
"statusCode": 201, | ||
"message": "Created. It appears to be good." | ||
} | ||
SelectionPattern: '201' | ||
StatusCode: 201 | ||
- ResponseTemplates: | ||
application/json: | | ||
{ | ||
"statusCode": 500, | ||
"message": "Internal Server Error. Houston, we have a problem." | ||
} | ||
SelectionPattern: '500' | ||
StatusCode: 500 | ||
- ResponseTemplates: | ||
application/json: | | ||
{ | ||
"statusCode": 503, | ||
"message": "Service Unavailable. I am not ready yet." | ||
} | ||
SelectionPattern: '503' | ||
StatusCode: 503 | ||
PassthroughBehavior: WHEN_NO_TEMPLATES | ||
RequestTemplates: | ||
application/json: | | ||
{ | ||
#if ( $input.params('method') == "ok" ) | ||
"statusCode": 200 | ||
#elseif ( $input.params('method') == "created" ) | ||
"statusCode": 201 | ||
#elseif ( $input.params('method') == "internalerror" ) | ||
"statusCode": 500 | ||
#else | ||
"statusCode": 503 | ||
#end | ||
} | ||
Type: MOCK | ||
TimeoutInMillis: 29000 | ||
OperationName: 'mock' | ||
ResourceId: !Ref Resource | ||
RestApiId: !Ref RestApi | ||
|
||
PostMethod: | ||
Type: AWS::ApiGateway::Method | ||
Properties: | ||
ApiKeyRequired: false | ||
AuthorizationType: NONE | ||
HttpMethod: POST | ||
MethodResponses: | ||
- ResponseModels: | ||
application/json: !Ref ApiGatewayModel | ||
StatusCode: 200 | ||
- ResponseModels: | ||
application/json: !Ref ApiGatewayModel | ||
StatusCode: 500 | ||
Integration: | ||
ConnectionType: INTERNET | ||
IntegrationResponses: | ||
- ResponseTemplates: | ||
application/json: "{\"message\": \"OK. No problem here.\"}" | ||
# SelectionPattern: '2\d{2}' | ||
StatusCode: 200 | ||
- ResponseTemplates: | ||
application/json: "{\"message\": \"Internal Server Error. Houston, we have a problem.\"}" | ||
SelectionPattern: '5\d{2}' | ||
StatusCode: 500 | ||
PassthroughBehavior: WHEN_NO_TEMPLATES | ||
RequestTemplates: | ||
application/json: | | ||
{ | ||
"statusCode": $input.json('$.statusCode'), | ||
"message": $input.json('$.message') | ||
} | ||
Type: MOCK | ||
TimeoutInMillis: 29000 | ||
OperationName: 'mock' | ||
ResourceId: !Ref Resource | ||
RestApiId: !Ref RestApi | ||
|
||
ApiGatewayModel: | ||
Type: AWS::ApiGateway::Model | ||
Properties: | ||
ContentType: 'application/json' | ||
RestApiId: !Ref RestApi | ||
Schema: {} | ||
|
||
ApiGatewayStage: | ||
Type: AWS::ApiGateway::Stage | ||
Properties: | ||
DeploymentId: !Ref ApiGatewayDeployment | ||
Description: Mock API Stage v0 | ||
RestApiId: !Ref RestApi | ||
StageName: 'v0' | ||
|
||
ApiGatewayDeployment: | ||
Type: AWS::ApiGateway::Deployment | ||
DependsOn: | ||
- GetMethod | ||
- PostMethod | ||
Properties: | ||
Description: Mock API Deployment | ||
RestApiId: !Ref RestApi |