Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bin/sam-translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import boto3
from docopt import docopt

my_path = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, my_path + '/..')

from samtranslator.public.translator import ManagedPolicyLoader
from samtranslator.translator.transform import transform
from samtranslator.yaml_helper import yaml_parse
Expand Down
10 changes: 0 additions & 10 deletions examples/2016-10-31/api_gateway_responses/src/index.js

This file was deleted.

31 changes: 8 additions & 23 deletions examples/2016-10-31/api_gateway_responses/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,31 @@ Transform: AWS::Serverless-2016-10-31
Description: Simple webservice deomnstrating gateway responses.

Resources:
ExplicitApi:
MyApi:
Type: AWS::Serverless::Api
Properties:
Auth:
Authorizers:
Authorizer:
FunctionArn: !GetAtt AuthorizerFunction.Arn
Identity:
ValidationExpression: "^Bearer +[-0-9a-zA-Z\\._]*$"
ReauthorizeEvery: 300
StageName: Prod
GatewayResponses:
UNAUTHORIZED:
DEFAULT_4xx:
ResponseParameters:
Headers:
Access-Control-Expose-Headers: "'WWW-Authenticate'"
Access-Control-Allow-Origin: "'*'"
WWW-Authenticate: >-
'Bearer realm="admin"'

GetFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.get
Runtime: nodejs6.10
CodeUri: src/
InlineCode: module.exports = async () => throw new Error('Check out the response headers!')
Events:
GetResource:
Type: Api
Properties:
Path: /resource/{resourceId}
Path: /error
Method: get
Auth:
Authorizer: Authorizer
RestApiId: !Ref ExplicitApi
AuthorizerFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.auth
Runtime: nodejs6.10
CodeUri: src/
RestApiId: !Ref MyApi
Outputs:
ApiURL:
Description: "API endpoint URL for Prod environment"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/resource/"
Value: !Sub "https://${MyApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/error/"