diff --git a/bin/sam-translate.py b/bin/sam-translate.py index eda75b030f..2483bd4e40 100755 --- a/bin/sam-translate.py +++ b/bin/sam-translate.py @@ -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 diff --git a/examples/2016-10-31/api_gateway_responses/src/index.js b/examples/2016-10-31/api_gateway_responses/src/index.js deleted file mode 100644 index a6fe27fff5..0000000000 --- a/examples/2016-10-31/api_gateway_responses/src/index.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; -const createResponse = (statusCode, body) => ({ statusCode, body }); - -exports.get = (event, context, callback) => { - callback(null, createResponse(200, 'You will never see this.')); -}; - -exports.auth = (event, context, callback) => { - return callback('Unauthorized', null) -}; diff --git a/examples/2016-10-31/api_gateway_responses/template.yaml b/examples/2016-10-31/api_gateway_responses/template.yaml index 0f094e5589..6b0bafcdb4 100644 --- a/examples/2016-10-31/api_gateway_responses/template.yaml +++ b/examples/2016-10-31/api_gateway_responses/template.yaml @@ -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/"