Skip to content

Commit 7b16fbb

Browse files
brettstackjlhood
authored andcommitted
docs: fix/update GatewayResponses example (#879)
1 parent 116f948 commit 7b16fbb

File tree

3 files changed

+11
-33
lines changed

3 files changed

+11
-33
lines changed

bin/sam-translate.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
import boto3
2929
from docopt import docopt
3030

31+
my_path = os.path.dirname(os.path.abspath(__file__))
32+
sys.path.insert(0, my_path + '/..')
33+
3134
from samtranslator.public.translator import ManagedPolicyLoader
3235
from samtranslator.translator.transform import transform
3336
from samtranslator.yaml_helper import yaml_parse

examples/2016-10-31/api_gateway_responses/src/index.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/2016-10-31/api_gateway_responses/template.yaml

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,31 @@ Transform: AWS::Serverless-2016-10-31
33
Description: Simple webservice deomnstrating gateway responses.
44

55
Resources:
6-
ExplicitApi:
6+
MyApi:
77
Type: AWS::Serverless::Api
88
Properties:
9-
Auth:
10-
Authorizers:
11-
Authorizer:
12-
FunctionArn: !GetAtt AuthorizerFunction.Arn
13-
Identity:
14-
ValidationExpression: "^Bearer +[-0-9a-zA-Z\\._]*$"
15-
ReauthorizeEvery: 300
9+
StageName: Prod
1610
GatewayResponses:
17-
UNAUTHORIZED:
11+
DEFAULT_4xx:
1812
ResponseParameters:
1913
Headers:
2014
Access-Control-Expose-Headers: "'WWW-Authenticate'"
2115
Access-Control-Allow-Origin: "'*'"
22-
WWW-Authenticate: >-
23-
'Bearer realm="admin"'
16+
2417
GetFunction:
2518
Type: AWS::Serverless::Function
2619
Properties:
2720
Handler: index.get
2821
Runtime: nodejs6.10
29-
CodeUri: src/
22+
InlineCode: module.exports = async () => throw new Error('Check out the response headers!')
3023
Events:
3124
GetResource:
3225
Type: Api
3326
Properties:
34-
Path: /resource/{resourceId}
27+
Path: /error
3528
Method: get
36-
Auth:
37-
Authorizer: Authorizer
38-
RestApiId: !Ref ExplicitApi
39-
AuthorizerFunction:
40-
Type: AWS::Serverless::Function
41-
Properties:
42-
Handler: index.auth
43-
Runtime: nodejs6.10
44-
CodeUri: src/
29+
RestApiId: !Ref MyApi
4530
Outputs:
4631
ApiURL:
4732
Description: "API endpoint URL for Prod environment"
48-
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/resource/"
33+
Value: !Sub "https://${MyApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/error/"

0 commit comments

Comments
 (0)