From 8da229582b32d301baec59d912a02e9363f7b2d8 Mon Sep 17 00:00:00 2001 From: Shreya Gangishetty Date: Mon, 23 Sep 2019 17:33:10 -0700 Subject: [PATCH 1/2] revert request parameters commit: (#953) --- .../function_request_parameters/src/index.js | 6 - .../function_request_parameters/template.yaml | 33 ----- samtranslator/model/eventsources/push.py | 60 +------- samtranslator/swagger/swagger.py | 48 ------- tests/swagger/test_swagger.py | 134 ------------------ ...r_function_invalid_request_parameters.yaml | 109 -------------- .../function_with_request_parameters.yaml | 40 ------ ...r_function_invalid_request_parameters.json | 3 - tests/translator/test_translator.py | 2 - versions/2016-10-31.md | 12 -- 10 files changed, 1 insertion(+), 446 deletions(-) delete mode 100644 examples/2016-10-31/function_request_parameters/src/index.js delete mode 100644 examples/2016-10-31/function_request_parameters/template.yaml delete mode 100644 tests/translator/input/error_function_invalid_request_parameters.yaml delete mode 100644 tests/translator/input/function_with_request_parameters.yaml delete mode 100644 tests/translator/output/error_function_invalid_request_parameters.json diff --git a/examples/2016-10-31/function_request_parameters/src/index.js b/examples/2016-10-31/function_request_parameters/src/index.js deleted file mode 100644 index 7f7a6018d..000000000 --- a/examples/2016-10-31/function_request_parameters/src/index.js +++ /dev/null @@ -1,6 +0,0 @@ -exports.handler = function(event, context, callback) { - callback(null, { - "statusCode": 200, - "body": "hello world" - }); -} diff --git a/examples/2016-10-31/function_request_parameters/template.yaml b/examples/2016-10-31/function_request_parameters/template.yaml deleted file mode 100644 index e6334b98a..000000000 --- a/examples/2016-10-31/function_request_parameters/template.yaml +++ /dev/null @@ -1,33 +0,0 @@ -AWSTemplateFormatVersion: '2010-09-09' -Transform: AWS::Serverless-2016-10-31 -Description: Simple API Endpoint configured using Swagger specified inline and backed by a Lambda function -Globals: - Api: - CacheClusterEnabled: true - CacheClusterSize: '0.5' - -Resources: - - MyLambdaFunction: - Type: AWS::Serverless::Function - Properties: - Handler: index.handler - Runtime: nodejs8.10 - CodeUri: src/ - Events: - GetApi: - Type: Api - Properties: - Path: /post - Method: POST - RequestParameters: - - method.request.header.Authorization: - Required: true - Caching: true - - method.request.querystring.type - -Outputs: - - ApiURL: - Description: "API endpoint URL for Prod environment" - Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/post" \ No newline at end of file diff --git a/samtranslator/model/eventsources/push.py b/samtranslator/model/eventsources/push.py index 62341e983..40ee8d38e 100644 --- a/samtranslator/model/eventsources/push.py +++ b/samtranslator/model/eventsources/push.py @@ -21,8 +21,6 @@ CONDITION = 'Condition' -REQUEST_PARAMETER_PROPERTIES = ["Required", "Caching"] - class PushEventSource(ResourceMacro): """Base class for push event sources for SAM Functions. @@ -451,8 +449,7 @@ class Api(PushEventSource): 'RestApiId': PropertyType(True, is_str()), 'Stage': PropertyType(False, is_str()), 'Auth': PropertyType(False, is_type(dict)), - 'RequestModel': PropertyType(False, is_type(dict)), - 'RequestParameters': PropertyType(False, is_type(list)) + 'RequestModel': PropertyType(False, is_type(dict)) } def resources_to_link(self, resources): @@ -666,61 +663,6 @@ def _add_swagger_integration(self, api, function): editor.add_request_model_to_method(path=self.Path, method_name=self.Method, request_model=self.RequestModel) - if self.RequestParameters: - - default_value = { - 'Required': False, - 'Caching': False - } - - parameters = [] - for parameter in self.RequestParameters: - - if isinstance(parameter, dict): - - parameter_name, parameter_value = next(iter(parameter.items())) - - if not re.match('method\.request\.(querystring|path|header)\.', parameter_name): - raise InvalidEventException( - self.relative_id, - "Invalid value for 'RequestParameters' property. Keys must be in the format " - "'method.request.[querystring|path|header].{value}', " - "e.g 'method.request.header.Authorization'.") - - if not isinstance(parameter_value, dict) or not all(key in REQUEST_PARAMETER_PROPERTIES - for key in parameter_value.keys()): - raise InvalidEventException( - self.relative_id, - "Invalid value for 'RequestParameters' property. Values must be an object, " - "e.g { Required: true, Caching: false }") - - settings = default_value.copy() - settings.update(parameter_value) - settings.update({'Name': parameter_name}) - - parameters.append(settings) - - elif isinstance(parameter, string_types): - if not re.match('method\.request\.(querystring|path|header)\.', parameter): - raise InvalidEventException( - self.relative_id, - "Invalid value for 'RequestParameters' property. Keys must be in the format " - "'method.request.[querystring|path|header].{value}', " - "e.g 'method.request.header.Authorization'.") - - settings = default_value.copy() - settings.update({'Name': parameter}) - - parameters.append(settings) - - else: - raise InvalidEventException( - self.relative_id, - "Invalid value for 'RequestParameters' property. Property must be either a string or an object") - - editor.add_request_parameters_to_method(path=self.Path, method_name=self.Method, - request_parameters=parameters) - api["DefinitionBody"] = editor.swagger diff --git a/samtranslator/swagger/swagger.py b/samtranslator/swagger/swagger.py index ad9b881aa..3b5d3f398 100644 --- a/samtranslator/swagger/swagger.py +++ b/samtranslator/swagger/swagger.py @@ -24,7 +24,6 @@ class SwaggerEditor(object): _X_APIGW_GATEWAY_RESPONSES = 'x-amazon-apigateway-gateway-responses' _X_APIGW_POLICY = 'x-amazon-apigateway-policy' _X_ANY_METHOD = 'x-amazon-apigateway-any-method' - _CACHE_KEY_PARAMETERS = 'cacheKeyParameters' # https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html _ALL_HTTP_METHODS = ["OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE", "PATCH"] _POLICY_TYPE_IAM = "Iam" @@ -1004,53 +1003,6 @@ def _add_custom_statement(self, custom_statements): statement.extend(custom_statements) self.resource_policy['Statement'] = statement - def add_request_parameters_to_method(self, path, method_name, request_parameters): - """ - Add Parameters to Swagger. - - :param string path: Path name - :param string method_name: Method name - :param list request_parameters: Dictionary of Parameters - :return: - """ - - normalized_method_name = self._normalize_method_name(method_name) - # It is possible that the method could have two definitions in a Fn::If block. - for method_definition in self.get_method_contents(self.get_path(path)[normalized_method_name]): - - # If no integration given, then we don't need to process this definition (could be AWS::NoValue) - if not self.method_definition_has_integration(method_definition): - continue - - existing_parameters = method_definition.get('parameters', []) - - for request_parameter in request_parameters: - - parameter_name = request_parameter['Name'] - location_name = parameter_name.replace('method.request.', '') - location, name = location_name.split('.') - - if location == 'querystring': - location = 'query' - - parameter = { - 'in': location, - 'name': name, - 'required': request_parameter['Required'], - 'type': 'string' - } - - existing_parameters.append(parameter) - - if request_parameter['Caching']: - - integration = method_definition[self._X_APIGW_INTEGRATION] - cache_parameters = integration.get(self._CACHE_KEY_PARAMETERS, []) - cache_parameters.append(parameter_name) - integration[self._CACHE_KEY_PARAMETERS] = cache_parameters - - method_definition['parameters'] = existing_parameters - @property def swagger(self): """ diff --git a/tests/swagger/test_swagger.py b/tests/swagger/test_swagger.py index 5afbe2888..bbd854ae0 100644 --- a/tests/swagger/test_swagger.py +++ b/tests/swagger/test_swagger.py @@ -1237,140 +1237,6 @@ def test_set_method_apikey_handling_apikeyrequired_true(self): self.assertEqual(expected, self.editor.swagger["paths"][path][method]["security"]) -class TestSwaggerEditor_add_request_parameter_to_method(TestCase): - - def setUp(self): - self.original_swagger = { - "swagger": "2.0", - "paths": { - "/foo": { - 'get': { - 'x-amazon-apigateway-integration': { - 'test': 'must have integration' - } - } - } - } - } - - self.editor = SwaggerEditor(self.original_swagger) - - def test_must_add_parameter_to_method_with_required_and_caching_true(self): - - parameters = [{ - 'Name': 'method.request.header.Authorization', - 'Required': True, - 'Caching': True - }] - - self.editor.add_request_parameters_to_method('/foo', 'get', parameters) - - expected_parameters = [ - { - 'in': 'header', - 'required': True, - 'name': 'Authorization', - 'type': 'string' - } - ] - - method_swagger = self.editor.swagger['paths']['/foo']['get'] - - self.assertEqual(expected_parameters, method_swagger['parameters']) - self.assertEqual(['method.request.header.Authorization'], method_swagger[_X_INTEGRATION]['cacheKeyParameters']) - - def test_must_add_parameter_to_method_with_required_and_caching_false(self): - - parameters = [{ - 'Name': 'method.request.header.Authorization', - 'Required': False, - 'Caching': False - }] - - self.editor.add_request_parameters_to_method('/foo', 'get', parameters) - - expected_parameters = [ - { - 'in': 'header', - 'required': False, - 'name': 'Authorization', - 'type': 'string' - } - ] - - method_swagger = self.editor.swagger['paths']['/foo']['get'] - - self.assertEqual(expected_parameters, method_swagger['parameters']) - self.assertNotIn('cacheKeyParameters', method_swagger[_X_INTEGRATION].keys()) - - def test_must_add_parameter_to_method_with_existing_parameters(self): - - original_swagger = { - "swagger": "2.0", - "paths": { - "/foo": { - 'get': { - 'x-amazon-apigateway-integration': { - 'test': 'must have integration' - }, - 'parameters': [{'test': 'existing parameter'}] - } - } - } - } - - editor = SwaggerEditor(original_swagger) - - parameters = [{ - 'Name': 'method.request.header.Authorization', - 'Required': False, - 'Caching': False - }] - - editor.add_request_parameters_to_method('/foo', 'get', parameters) - - expected_parameters = [ - { - 'test': 'existing parameter' - }, - { - 'in': 'header', - 'required': False, - 'name': 'Authorization', - 'type': 'string' - } - ] - - method_swagger = editor.swagger['paths']['/foo']['get'] - - self.assertEqual(expected_parameters, method_swagger['parameters']) - self.assertNotIn('cacheKeyParameters', method_swagger[_X_INTEGRATION].keys()) - - def test_must_not_add_parameter_to_method_without_integration(self): - original_swagger = { - "swagger": "2.0", - "paths": { - "/foo": { - 'get': {} - } - } - } - - editor = SwaggerEditor(original_swagger) - - parameters = [{ - 'Name': 'method.request.header.Authorization', - 'Required': True, - 'Caching': True - }] - - editor.add_request_parameters_to_method('/foo', 'get', parameters) - - expected = {} - - self.assertEqual(expected, editor.swagger['paths']['/foo']['get']) - - class TestSwaggerEditor_add_resource_policy(TestCase): def setUp(self): diff --git a/tests/translator/input/error_function_invalid_request_parameters.yaml b/tests/translator/input/error_function_invalid_request_parameters.yaml deleted file mode 100644 index 16f2fa68b..000000000 --- a/tests/translator/input/error_function_invalid_request_parameters.yaml +++ /dev/null @@ -1,109 +0,0 @@ -Resources: - - InvalidNameStringParameterFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/member_portal.zip - Handler: index.gethtml - Runtime: nodejs4.3 - Events: - GetHtml: - Type: Api - Properties: - Path: / - Method: get - RequestParameters: - - Authorization - - InvalidNameLocationStringParameterFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/member_portal.zip - Handler: index.gethtml - Runtime: nodejs4.3 - Events: - GetHtml: - Type: Api - Properties: - Path: / - Method: get - RequestParameters: - - method.request.invalid.Authorization - - InvalidNameDictParameterFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/member_portal.zip - Handler: index.gethtml - Runtime: nodejs4.3 - Events: - GetHtml: - Type: Api - Properties: - Path: / - Method: get - RequestParameters: - - Authorization: - Required: true - - InvalidNameLocationDictParameterFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/member_portal.zip - Handler: index.gethtml - Runtime: nodejs4.3 - Events: - GetHtml: - Type: Api - Properties: - Path: / - Method: get - RequestParameters: - - method.request.invalid.Authorization: - Required: true - - ParameterNotDictFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/member_portal.zip - Handler: index.gethtml - Runtime: nodejs4.3 - Events: - GetHtml: - Type: Api - Properties: - Path: / - Method: get - RequestParameters: - - method.request.header.Authorization: notadict - - ParameterInvalidFieldFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/member_portal.zip - Handler: index.gethtml - Runtime: nodejs4.3 - Events: - GetHtml: - Type: Api - Properties: - Path: / - Method: get - RequestParameters: - - method.request.header.Authorization: - invalid: field - - ParameterNotDictOrStringFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/member_portal.zip - Handler: index.gethtml - Runtime: nodejs4.3 - Events: - GetHtml: - Type: Api - Properties: - Path: / - Method: get - RequestParameters: - - [Authorization] diff --git a/tests/translator/input/function_with_request_parameters.yaml b/tests/translator/input/function_with_request_parameters.yaml deleted file mode 100644 index ebc89f893..000000000 --- a/tests/translator/input/function_with_request_parameters.yaml +++ /dev/null @@ -1,40 +0,0 @@ -Resources: - - Api: - Type: AWS::Serverless::Api - Properties: - StageName: Prod - - ApiParameterFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/member_portal.zip - Handler: index.gethtml - Runtime: nodejs4.3 - Events: - GetHtml: - Type: Api - Properties: - RestApiId: Api - Path: / - Method: get - RequestParameters: - - method.request.header.Authorization: - Required: true - Caching: true - - NoApiParameterFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/member_portal.zip - Handler: index.gethtml - Runtime: nodejs4.3 - Events: - GetHtml: - Type: Api - Properties: - Path: / - Method: get - RequestParameters: - - method.request.querystring.type - - method.request.path.id diff --git a/tests/translator/output/error_function_invalid_request_parameters.json b/tests/translator/output/error_function_invalid_request_parameters.json deleted file mode 100644 index cfc869006..000000000 --- a/tests/translator/output/error_function_invalid_request_parameters.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 6. Resource with id [InvalidNameDictParameterFunction] is invalid. Event with id [GetHtml] is invalid. Invalid value for 'RequestParameters' property. Keys must be in the format 'method.request.[querystring|path|header].{value}', e.g 'method.request.header.Authorization'. Resource with id [InvalidNameLocationStringParameterFunction] is invalid. Event with id [GetHtml] is invalid. Invalid value for 'RequestParameters' property. Keys must be in the format 'method.request.[querystring|path|header].{value}', e.g 'method.request.header.Authorization'. Resource with id [InvalidNameStringParameterFunction] is invalid. Event with id [GetHtml] is invalid. Invalid value for 'RequestParameters' property. Keys must be in the format 'method.request.[querystring|path|header].{value}', e.g 'method.request.header.Authorization'. Resource with id [ParameterInvalidFieldFunction] is invalid. Event with id [GetHtml] is invalid. Invalid value for 'RequestParameters' property. Values must be an object, e.g { Required: true, Caching: false } Resource with id [ParameterNotDictFunction] is invalid. Event with id [GetHtml] is invalid. Invalid value for 'RequestParameters' property. Values must be an object, e.g { Required: true, Caching: false } Resource with id [ParameterNotDictOrStringFunction] is invalid. Event with id [GetHtml] is invalid. Invalid value for 'RequestParameters' property. Property must be either a string or an object" -} \ No newline at end of file diff --git a/tests/translator/test_translator.py b/tests/translator/test_translator.py index b29eb843b..0866b7452 100644 --- a/tests/translator/test_translator.py +++ b/tests/translator/test_translator.py @@ -236,7 +236,6 @@ class TestTranslatorEndToEnd(TestCase): 'function_with_conditional_managed_policy_and_ref_no_value', 'function_with_conditional_policy_template', 'function_with_conditional_policy_template_and_ref_no_value', - 'function_with_request_parameters', 'global_handle_path_level_parameter', 'globals_for_function', 'globals_for_api', @@ -512,7 +511,6 @@ def _generate_new_deployment_hash(self, logical_id, dict_to_hash, rest_api_to_sw 'error_function_no_runtime', 'error_function_with_deployment_preference_missing_alias', 'error_function_with_invalid_deployment_preference_hook_property', - 'error_function_invalid_request_parameters', 'error_invalid_logical_id', 'error_layer_invalid_properties', 'error_missing_queue', diff --git a/versions/2016-10-31.md b/versions/2016-10-31.md index a37cf42d6..96b2b8c1b 100644 --- a/versions/2016-10-31.md +++ b/versions/2016-10-31.md @@ -536,7 +536,6 @@ Method | `string` | **Required.** HTTP method for which this function is invoked RestApiId | `string` | Identifier of a RestApi resource which MUST contain an operation with the given path and method. Typically, this is set to [reference](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html) an `AWS::Serverless::Api` resource defined in this template. If not defined, a default `AWS::Serverless::Api` resource is created using a generated Swagger document contains a union of all paths and methods defined by `Api` events defined in this template that do not specify a RestApiId. Auth | [Function Auth Object](#function-auth-object) | Auth configuration for this specific Api+Path+Method. Useful for overriding the API's `DefaultAuthorizer` setting auth config on an individual path when no `DefaultAuthorizer` is specified or overriding the default `ApiKeyRequired` setting. RequestModel | [Function Request Model Object](#function-request-model-object) | Request model configuration for this specific Api+Path+Method. -RequestParameters | List of `string` | List of [Function Request Parameter Object](#function-request-parameter-object) | Request parameters configuration for this specific Api+Path+Method. All parameter names must start with `method.request` and must be limited to `method.request.header`, `method.request.querystring`, or `method.request.path`. If a parameter is a `string` and NOT a [Function Request Parameter Object](#function-request-parameter-object) then `Required` and `Caching` will default to `False`. ##### Example: Api event source object @@ -737,7 +736,6 @@ Properties: - [API Auth Object](#api-auth-object) - [Function Auth Object](#function-auth-object) - [Function Request Model Object](#function-request-model-object) -- [Function Request Parameter Object](#function-request-parameter-object) - [Gateway Response Object](#gateway-response-object) #### S3 Location Object @@ -947,16 +945,6 @@ RequestModel: Required: true # OPTIONAL; boolean ``` -#### Function Request Parameter Object - -Configure Request Parameter for a specific Api+Path+Method. - -```yaml -- method.request.header.Authorization: - Required: true - Caching: true -``` - #### Gateway Response Object Configure Gateway Responses on APIs. These are associated with the ID of a Gateway Response [response type][]. From 1af320731e3cd484f0c0ef6c65314185b8a6739d Mon Sep 17 00:00:00 2001 From: Shreya Gangishetty Date: Mon, 23 Sep 2019 17:40:28 -0700 Subject: [PATCH 2/2] removed the output test files --- .../function_with_request_parameters.json | 279 ------------------ .../function_with_request_parameters.json | 279 ------------------ .../function_with_request_parameters.json | 263 ----------------- 3 files changed, 821 deletions(-) delete mode 100644 tests/translator/output/aws-cn/function_with_request_parameters.json delete mode 100644 tests/translator/output/aws-us-gov/function_with_request_parameters.json delete mode 100644 tests/translator/output/function_with_request_parameters.json diff --git a/tests/translator/output/aws-cn/function_with_request_parameters.json b/tests/translator/output/aws-cn/function_with_request_parameters.json deleted file mode 100644 index 720233309..000000000 --- a/tests/translator/output/aws-cn/function_with_request_parameters.json +++ /dev/null @@ -1,279 +0,0 @@ -{ - "Resources": { - "ApiParameterFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Handler": "index.gethtml", - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "member_portal.zip" - }, - "Role": { - "Fn::GetAtt": [ - "ApiParameterFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs4.3", - "Tags": [ - { - "Value": "SAM", - "Key": "lambda:createdBy" - } - ] - } - }, - "NoApiParameterFunctionRole": { - "Type": "AWS::IAM::Role", - "Properties": { - "ManagedPolicyArns": [ - "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], - "AssumeRolePolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Action": [ - "sts:AssumeRole" - ], - "Effect": "Allow", - "Principal": { - "Service": [ - "lambda.amazonaws.com" - ] - } - } - ] - } - } - }, - "ServerlessRestApiDeploymentc2741b5220": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "Description": "RestApi deployment id: c2741b5220c940a753e3d1e18da6763aaba1c19b", - "StageName": "Stage" - } - }, - "ApiParameterFunctionRole": { - "Type": "AWS::IAM::Role", - "Properties": { - "ManagedPolicyArns": [ - "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], - "AssumeRolePolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Action": [ - "sts:AssumeRole" - ], - "Effect": "Allow", - "Principal": { - "Service": [ - "lambda.amazonaws.com" - ] - } - } - ] - } - } - }, - "NoApiParameterFunctionGetHtmlPermissionProd": { - "Type": "AWS::Lambda::Permission", - "Properties": { - "Action": "lambda:invokeFunction", - "Principal": "apigateway.amazonaws.com", - "FunctionName": { - "Ref": "NoApiParameterFunction" - }, - "SourceArn": { - "Fn::Sub": [ - "arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/", - { - "__Stage__": "*", - "__ApiId__": { - "Ref": "ServerlessRestApi" - } - } - ] - } - } - }, - "ServerlessRestApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "ServerlessRestApiDeploymentc2741b5220" - }, - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "StageName": "Prod" - } - }, - "ApiDeploymentd779e9df57": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "Api" - }, - "Description": "RestApi deployment id: d779e9df577321942ace63ca5592fbc8ba6fa9ec", - "StageName": "Stage" - } - }, - "Api": { - "Type": "AWS::ApiGateway::RestApi", - "Properties": { - "Body": { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/": { - "get": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws-cn:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ApiParameterFunction.Arn}/invocations" - }, - "cacheKeyParameters": [ - "method.request.header.Authorization" - ] - }, - "responses": {}, - "parameters": [ - { - "required": true, - "type": "string", - "name": "Authorization", - "in": "header" - } - ] - } - } - }, - "swagger": "2.0" - }, - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "Parameters": { - "endpointConfigurationTypes": "REGIONAL" - } - } - }, - "ApiParameterFunctionGetHtmlPermissionProd": { - "Type": "AWS::Lambda::Permission", - "Properties": { - "Action": "lambda:invokeFunction", - "Principal": "apigateway.amazonaws.com", - "FunctionName": { - "Ref": "ApiParameterFunction" - }, - "SourceArn": { - "Fn::Sub": [ - "arn:aws-cn:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/", - { - "__Stage__": "*", - "__ApiId__": "Api" - } - ] - } - } - }, - "ApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "ApiDeploymentd779e9df57" - }, - "RestApiId": { - "Ref": "Api" - }, - "StageName": "Prod" - } - }, - "ServerlessRestApi": { - "Type": "AWS::ApiGateway::RestApi", - "Properties": { - "Body": { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/": { - "get": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws-cn:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${NoApiParameterFunction.Arn}/invocations" - } - }, - "responses": {}, - "parameters": [ - { - "required": false, - "type": "string", - "name": "type", - "in": "query" - }, - { - "required": false, - "type": "string", - "name": "id", - "in": "path" - } - ] - } - } - }, - "swagger": "2.0" - }, - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "Parameters": { - "endpointConfigurationTypes": "REGIONAL" - } - } - }, - "NoApiParameterFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Handler": "index.gethtml", - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "member_portal.zip" - }, - "Role": { - "Fn::GetAtt": [ - "NoApiParameterFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs4.3", - "Tags": [ - { - "Value": "SAM", - "Key": "lambda:createdBy" - } - ] - } - } - } -} \ No newline at end of file diff --git a/tests/translator/output/aws-us-gov/function_with_request_parameters.json b/tests/translator/output/aws-us-gov/function_with_request_parameters.json deleted file mode 100644 index 45eed3c15..000000000 --- a/tests/translator/output/aws-us-gov/function_with_request_parameters.json +++ /dev/null @@ -1,279 +0,0 @@ -{ - "Resources": { - "ApiParameterFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Handler": "index.gethtml", - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "member_portal.zip" - }, - "Role": { - "Fn::GetAtt": [ - "ApiParameterFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs4.3", - "Tags": [ - { - "Value": "SAM", - "Key": "lambda:createdBy" - } - ] - } - }, - "NoApiParameterFunctionRole": { - "Type": "AWS::IAM::Role", - "Properties": { - "ManagedPolicyArns": [ - "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], - "AssumeRolePolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Action": [ - "sts:AssumeRole" - ], - "Effect": "Allow", - "Principal": { - "Service": [ - "lambda.amazonaws.com" - ] - } - } - ] - } - } - }, - "ServerlessRestApiDeployment7c706bcd56": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "Description": "RestApi deployment id: 7c706bcd56e685afb5882e0219515c9413bcd13b", - "StageName": "Stage" - } - }, - "ApiDeployment5e67eb8be3": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "Api" - }, - "Description": "RestApi deployment id: 5e67eb8be3d6956bbeadcb3ffdae9abcac90f01e", - "StageName": "Stage" - } - }, - "ApiParameterFunctionRole": { - "Type": "AWS::IAM::Role", - "Properties": { - "ManagedPolicyArns": [ - "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], - "AssumeRolePolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Action": [ - "sts:AssumeRole" - ], - "Effect": "Allow", - "Principal": { - "Service": [ - "lambda.amazonaws.com" - ] - } - } - ] - } - } - }, - "NoApiParameterFunctionGetHtmlPermissionProd": { - "Type": "AWS::Lambda::Permission", - "Properties": { - "Action": "lambda:invokeFunction", - "Principal": "apigateway.amazonaws.com", - "FunctionName": { - "Ref": "NoApiParameterFunction" - }, - "SourceArn": { - "Fn::Sub": [ - "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/", - { - "__Stage__": "*", - "__ApiId__": { - "Ref": "ServerlessRestApi" - } - } - ] - } - } - }, - "ServerlessRestApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "ServerlessRestApiDeployment7c706bcd56" - }, - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "StageName": "Prod" - } - }, - "Api": { - "Type": "AWS::ApiGateway::RestApi", - "Properties": { - "Body": { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/": { - "get": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws-us-gov:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ApiParameterFunction.Arn}/invocations" - }, - "cacheKeyParameters": [ - "method.request.header.Authorization" - ] - }, - "responses": {}, - "parameters": [ - { - "required": true, - "type": "string", - "name": "Authorization", - "in": "header" - } - ] - } - } - }, - "swagger": "2.0" - }, - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "Parameters": { - "endpointConfigurationTypes": "REGIONAL" - } - } - }, - "ApiParameterFunctionGetHtmlPermissionProd": { - "Type": "AWS::Lambda::Permission", - "Properties": { - "Action": "lambda:invokeFunction", - "Principal": "apigateway.amazonaws.com", - "FunctionName": { - "Ref": "ApiParameterFunction" - }, - "SourceArn": { - "Fn::Sub": [ - "arn:aws-us-gov:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/", - { - "__Stage__": "*", - "__ApiId__": "Api" - } - ] - } - } - }, - "ApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "ApiDeployment5e67eb8be3" - }, - "RestApiId": { - "Ref": "Api" - }, - "StageName": "Prod" - } - }, - "ServerlessRestApi": { - "Type": "AWS::ApiGateway::RestApi", - "Properties": { - "Body": { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/": { - "get": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws-us-gov:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${NoApiParameterFunction.Arn}/invocations" - } - }, - "responses": {}, - "parameters": [ - { - "required": false, - "type": "string", - "name": "type", - "in": "query" - }, - { - "required": false, - "type": "string", - "name": "id", - "in": "path" - } - ] - } - } - }, - "swagger": "2.0" - }, - "EndpointConfiguration": { - "Types": [ - "REGIONAL" - ] - }, - "Parameters": { - "endpointConfigurationTypes": "REGIONAL" - } - } - }, - "NoApiParameterFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Handler": "index.gethtml", - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "member_portal.zip" - }, - "Role": { - "Fn::GetAtt": [ - "NoApiParameterFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs4.3", - "Tags": [ - { - "Value": "SAM", - "Key": "lambda:createdBy" - } - ] - } - } - } -} \ No newline at end of file diff --git a/tests/translator/output/function_with_request_parameters.json b/tests/translator/output/function_with_request_parameters.json deleted file mode 100644 index 77dc1f50c..000000000 --- a/tests/translator/output/function_with_request_parameters.json +++ /dev/null @@ -1,263 +0,0 @@ -{ - "Resources": { - "ApiParameterFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Handler": "index.gethtml", - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "member_portal.zip" - }, - "Role": { - "Fn::GetAtt": [ - "ApiParameterFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs4.3", - "Tags": [ - { - "Value": "SAM", - "Key": "lambda:createdBy" - } - ] - } - }, - "NoApiParameterFunctionRole": { - "Type": "AWS::IAM::Role", - "Properties": { - "ManagedPolicyArns": [ - "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], - "AssumeRolePolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Action": [ - "sts:AssumeRole" - ], - "Effect": "Allow", - "Principal": { - "Service": [ - "lambda.amazonaws.com" - ] - } - } - ] - } - } - }, - "ServerlessRestApiDeployment2223b43914": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "Description": "RestApi deployment id: 2223b439142974b7a3aad1381ddd39027077ce52", - "StageName": "Stage" - } - }, - "ApiParameterFunctionRole": { - "Type": "AWS::IAM::Role", - "Properties": { - "ManagedPolicyArns": [ - "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ], - "AssumeRolePolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Action": [ - "sts:AssumeRole" - ], - "Effect": "Allow", - "Principal": { - "Service": [ - "lambda.amazonaws.com" - ] - } - } - ] - } - } - }, - "NoApiParameterFunctionGetHtmlPermissionProd": { - "Type": "AWS::Lambda::Permission", - "Properties": { - "Action": "lambda:invokeFunction", - "Principal": "apigateway.amazonaws.com", - "FunctionName": { - "Ref": "NoApiParameterFunction" - }, - "SourceArn": { - "Fn::Sub": [ - "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/", - { - "__Stage__": "*", - "__ApiId__": { - "Ref": "ServerlessRestApi" - } - } - ] - } - } - }, - "ServerlessRestApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "ServerlessRestApiDeployment2223b43914" - }, - "RestApiId": { - "Ref": "ServerlessRestApi" - }, - "StageName": "Prod" - } - }, - "Api": { - "Type": "AWS::ApiGateway::RestApi", - "Properties": { - "Body": { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/": { - "get": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ApiParameterFunction.Arn}/invocations" - }, - "cacheKeyParameters": [ - "method.request.header.Authorization" - ] - }, - "responses": {}, - "parameters": [ - { - "required": true, - "type": "string", - "name": "Authorization", - "in": "header" - } - ] - } - } - }, - "swagger": "2.0" - } - } - }, - "ApiParameterFunctionGetHtmlPermissionProd": { - "Type": "AWS::Lambda::Permission", - "Properties": { - "Action": "lambda:invokeFunction", - "Principal": "apigateway.amazonaws.com", - "FunctionName": { - "Ref": "ApiParameterFunction" - }, - "SourceArn": { - "Fn::Sub": [ - "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/", - { - "__Stage__": "*", - "__ApiId__": "Api" - } - ] - } - } - }, - "ApiDeploymentb45131471b": { - "Type": "AWS::ApiGateway::Deployment", - "Properties": { - "RestApiId": { - "Ref": "Api" - }, - "Description": "RestApi deployment id: b45131471b437edb4cca88487357f3bfbcf59866", - "StageName": "Stage" - } - }, - "ApiProdStage": { - "Type": "AWS::ApiGateway::Stage", - "Properties": { - "DeploymentId": { - "Ref": "ApiDeploymentb45131471b" - }, - "RestApiId": { - "Ref": "Api" - }, - "StageName": "Prod" - } - }, - "ServerlessRestApi": { - "Type": "AWS::ApiGateway::RestApi", - "Properties": { - "Body": { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/": { - "get": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${NoApiParameterFunction.Arn}/invocations" - } - }, - "responses": {}, - "parameters": [ - { - "required": false, - "type": "string", - "name": "type", - "in": "query" - }, - { - "required": false, - "type": "string", - "name": "id", - "in": "path" - } - ] - } - } - }, - "swagger": "2.0" - } - } - }, - "NoApiParameterFunction": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Handler": "index.gethtml", - "Code": { - "S3Bucket": "sam-demo-bucket", - "S3Key": "member_portal.zip" - }, - "Role": { - "Fn::GetAtt": [ - "NoApiParameterFunctionRole", - "Arn" - ] - }, - "Runtime": "nodejs4.3", - "Tags": [ - { - "Value": "SAM", - "Key": "lambda:createdBy" - } - ] - } - } - } -} \ No newline at end of file