From ac09c90cd2d9f686e40ac756454a65f13c3d6d07 Mon Sep 17 00:00:00 2001 From: Jacob Fuss <32497805+jfuss@users.noreply.github.com> Date: Fri, 28 Oct 2022 10:52:55 -0500 Subject: [PATCH 01/14] chore: Enforce Pytest Warnings (#4339) --- pytest.ini | 5 +++-- .../samlib/test_resource_metadata_normalizer.py | 14 +++++++------- tests/unit/local/apigw/test_local_apigw_service.py | 6 +++--- .../test_local_lambda_invoke_service.py | 8 ++++---- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/pytest.ini b/pytest.ini index 3db0fca22a..baa3adcfae 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,5 +2,6 @@ log_cli = 1 log_cli_level = INFO addopts = --maxfail=1000 -rf -#filterwarnings = -# error +filterwarnings = + error + ignore::DeprecationWarning:docker diff --git a/tests/unit/lib/samlib/test_resource_metadata_normalizer.py b/tests/unit/lib/samlib/test_resource_metadata_normalizer.py index 84123fc270..c4c0c2e877 100644 --- a/tests/unit/lib/samlib/test_resource_metadata_normalizer.py +++ b/tests/unit/lib/samlib/test_resource_metadata_normalizer.py @@ -434,7 +434,7 @@ def test_use_cdk_id_as_resource_id(self, cdk_path, expected_resource_id): "logical_id", ) - self.assertEquals(expected_resource_id, resource_id) + self.assertEqual(expected_resource_id, resource_id) def test_use_logical_id_as_resource_id_incase_of_invalid_cdk_path(self): resource_id = ResourceMetadataNormalizer.get_resource_id( @@ -442,7 +442,7 @@ def test_use_logical_id_as_resource_id_incase_of_invalid_cdk_path(self): "logical_id", ) - self.assertEquals("logical_id", resource_id) + self.assertEqual("logical_id", resource_id) def test_use_cdk_id_as_resource_id_for_nested_stack(self): resource_id = ResourceMetadataNormalizer.get_resource_id( @@ -456,7 +456,7 @@ def test_use_cdk_id_as_resource_id_for_nested_stack(self): "logical_id", ) - self.assertEquals("nested_stack_id", resource_id) + self.assertEqual("nested_stack_id", resource_id) def test_use_provided_customer_defined_id(self): resource_id = ResourceMetadataNormalizer.get_resource_id( @@ -468,7 +468,7 @@ def test_use_provided_customer_defined_id(self): "logical_id", ) - self.assertEquals("custom_id", resource_id) + self.assertEqual("custom_id", resource_id) def test_use_provided_customer_defined_id_for_nested_stack(self): resource_id = ResourceMetadataNormalizer.get_resource_id( @@ -483,21 +483,21 @@ def test_use_provided_customer_defined_id_for_nested_stack(self): "logical_id", ) - self.assertEquals("custom_nested_stack_id", resource_id) + self.assertEqual("custom_nested_stack_id", resource_id) def test_use_logical_id_if_metadata_is_not_therer(self): resource_id = ResourceMetadataNormalizer.get_resource_id( {"Type": "any:value", "Properties": {"key": "value"}}, "logical_id" ) - self.assertEquals("logical_id", resource_id) + self.assertEqual("logical_id", resource_id) def test_use_logical_id_if_cdk_path_not_exist(self): resource_id = ResourceMetadataNormalizer.get_resource_id( {"Type": "any:value", "Properties": {"key": "value"}, "Metadata": {}}, "logical_id" ) - self.assertEquals("logical_id", resource_id) + self.assertEqual("logical_id", resource_id) class TestResourceMetadataNormalizerBuildPropertiesNormalizer(TestCase): diff --git a/tests/unit/local/apigw/test_local_apigw_service.py b/tests/unit/local/apigw/test_local_apigw_service.py index a416b84d15..450d47a8e7 100644 --- a/tests/unit/local/apigw/test_local_apigw_service.py +++ b/tests/unit/local/apigw/test_local_apigw_service.py @@ -1759,7 +1759,7 @@ def test_path_converter_to_url_accepts_any_path(self): path_converter = CatchAllPathConverter(map) path = "/path/test/sub_path" output = path_converter.to_url(path) - self.assertEquals(path, output) + self.assertEqual(path, output) def test_path_converter_to_python_accepts_any_path(self): map = Mock() @@ -1767,11 +1767,11 @@ def test_path_converter_to_python_accepts_any_path(self): path_converter = CatchAllPathConverter(map) path = "/path/test/sub_path" output = path_converter.to_python(path) - self.assertEquals(path, output) + self.assertEqual(path, output) def test_path_converter_matches_any_path(self): map = Mock() map.charset = "utf-8" path_converter = CatchAllPathConverter(map) path = "/path/test/sub_path" - self.assertRegexpMatches(path, path_converter.regex) + self.assertRegex(path, path_converter.regex) diff --git a/tests/unit/local/lambda_service/test_local_lambda_invoke_service.py b/tests/unit/local/lambda_service/test_local_lambda_invoke_service.py index f426b79765..b93eff0e9f 100644 --- a/tests/unit/local/lambda_service/test_local_lambda_invoke_service.py +++ b/tests/unit/local/lambda_service/test_local_lambda_invoke_service.py @@ -45,7 +45,7 @@ def test_create_service_endpoints(self, flask_mock, error_handling_mock): methods=["POST"], provide_automatic_options=False, ) - self.assertEquals({"function_path": FunctionNamePathConverter}, app_mock.url_map.converters) + self.assertEqual({"function_path": FunctionNamePathConverter}, app_mock.url_map.converters) @patch("samcli.local.lambda_service.local_lambda_invoke_service.LocalLambdaInvokeService.service_response") @patch("samcli.local.lambda_service.local_lambda_invoke_service.LambdaOutputParser") @@ -274,7 +274,7 @@ def test_path_converter_to_url_accepts_function_full_path(self): path_converter = FunctionNamePathConverter(map) full_path = "parent_stack/function_id" output = path_converter.to_url(full_path) - self.assertEquals(full_path, output) + self.assertEqual(full_path, output) def test_path_converter_to_python_accepts_function_full_path(self): map = Mock() @@ -282,11 +282,11 @@ def test_path_converter_to_python_accepts_function_full_path(self): path_converter = FunctionNamePathConverter(map) full_path = "parent_stack/function_id" output = path_converter.to_python(full_path) - self.assertEquals(full_path, output) + self.assertEqual(full_path, output) def test_path_converter_matches_function_full_path(self): map = Mock() map.charset = "utf-8" path_converter = FunctionNamePathConverter(map) full_path = "parent_stack/function_id" - self.assertRegexpMatches(full_path, path_converter.regex) + self.assertRegex(full_path, path_converter.regex) From 435f81fa035e08442472da14d4db1c4d2de6db29 Mon Sep 17 00:00:00 2001 From: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com> Date: Fri, 28 Oct 2022 10:15:26 -0700 Subject: [PATCH 02/14] chore: bump golang version in CI jobs (#4352) --- appveyor-iac-integration-ubuntu.yml | 2 +- appveyor-ubuntu.yml | 2 +- appveyor.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor-iac-integration-ubuntu.yml b/appveyor-iac-integration-ubuntu.yml index 7559e21e3a..edfe86c0ed 100644 --- a/appveyor-iac-integration-ubuntu.yml +++ b/appveyor-iac-integration-ubuntu.yml @@ -38,7 +38,7 @@ install: # AppVeyor's apt-get cache might be outdated, and the package could potentially be 404. - sh: "sudo apt-get update" - - sh: "gvm use go1.15" + - sh: "gvm use go1.19" - sh: "echo $PATH" - sh: "ls /usr/" - sh: "JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64" diff --git a/appveyor-ubuntu.yml b/appveyor-ubuntu.yml index f88e8e8da0..25004f0a01 100644 --- a/appveyor-ubuntu.yml +++ b/appveyor-ubuntu.yml @@ -57,7 +57,7 @@ install: # AppVeyor's apt-get cache might be outdated, and the package could potentially be 404. - sh: "sudo apt-get update" - - sh: "gvm use go1.15" + - sh: "gvm use go1.19" - sh: "echo $PATH" - sh: "ls /usr/" - sh: "JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64" diff --git a/appveyor.yml b/appveyor.yml index 16de910e42..45707c4a88 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -123,7 +123,7 @@ for: # AppVeyor's apt-get cache might be outdated, and the package could potentially be 404. - sh: "sudo apt-get update" - - sh: "gvm use go1.15" + - sh: "gvm use go1.19" - sh: "echo $PATH" - sh: "ls /usr/" - sh: "JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64" From dd5a87f88c355ca1c9e15d0269b745820152e6f5 Mon Sep 17 00:00:00 2001 From: Sriram Madapusi Vasudevan <3770774+sriram-mv@users.noreply.github.com> Date: Tue, 1 Nov 2022 11:07:05 -0700 Subject: [PATCH 03/14] fix: regresssion on `sam delete` (#4362) * fix: regresssion on `sam delete` - Remove `MaxAttempts` and let it be set to default of 120 per https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudformation.html#waiters * unit: add additional unit test for the regression - assert the waiter config for `sam delete` operations. --- samcli/lib/delete/cfn_utils.py | 5 +++-- tests/unit/lib/delete/test_cfn_utils.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/samcli/lib/delete/cfn_utils.py b/samcli/lib/delete/cfn_utils.py index d61260b115..74523d0c4f 100644 --- a/samcli/lib/delete/cfn_utils.py +++ b/samcli/lib/delete/cfn_utils.py @@ -116,8 +116,9 @@ def wait_for_delete(self, stack_name): # Wait for Delete to Finish waiter = self._client.get_waiter("stack_delete_complete") - # Poll every 30 seconds and set max attempts to be 3. - waiter_config = {"Delay": 30, "MaxAttempts": 3} + # Remove `MaxAttempts` from waiter_config. + # Regression: https://github.com/aws/aws-sam-cli/issues/4361 + waiter_config = {"Delay": 30} try: waiter.wait(StackName=stack_name, WaiterConfig=waiter_config) except WaiterError as ex: diff --git a/tests/unit/lib/delete/test_cfn_utils.py b/tests/unit/lib/delete/test_cfn_utils.py index 467e751630..7cd2474aea 100644 --- a/tests/unit/lib/delete/test_cfn_utils.py +++ b/tests/unit/lib/delete/test_cfn_utils.py @@ -24,6 +24,7 @@ def setUp(self): self.cloudformation_client = self.session.client("cloudformation") self.s3_client = self.session.client("s3") self.cf_utils = CfnUtils(self.cloudformation_client) + self.waiter_config = {"Delay": 30} def test_cf_utils_init(self): self.assertEqual(self.cf_utils._client, self.cloudformation_client) @@ -105,6 +106,22 @@ def test_cf_utils_delete_stack_exception(self): with self.assertRaises(Exception): self.cf_utils.delete_stack("test", ["retain_logical_id"]) + def test_cf_utils_wait_for_delete_check_waiter_config(self): + exception = WaiterError( + name="wait_for_delete", + reason="unit-test", + last_response={"Stacks": [{"Status": "Failed", "StackStatusReason": "It's a unit test stack failure"}]}, + ) + # Patch MockDeleteWaiter's wait to be Mock to get access to call_args for assertion + with patch.object(MockDeleteWaiter, "wait", side_effect=exception): + self.cf_utils._client.get_waiter = MagicMock(return_value=MockDeleteWaiter()) + with self.assertRaises(DeleteFailedError): + self.cf_utils.wait_for_delete("test") + # Assert waiter config. + self.cf_utils._client.get_waiter.return_value.wait.assert_called_with( + StackName="test", WaiterConfig=self.waiter_config + ) + def test_cf_utils_wait_for_delete_exception_stack_status(self): self.cf_utils._client.get_waiter = MagicMock( return_value=MockDeleteWaiter( From bb30dbae2ebf0da2b15c2517cd37f42f7f7396fa Mon Sep 17 00:00:00 2001 From: Praneeta Prakash Date: Tue, 1 Nov 2022 15:27:38 -0700 Subject: [PATCH 04/14] Updated readme (#4367) * updating workshop link * Update README.md Co-authored-by: Chris Rehn <1280602+hoffa@users.noreply.github.com> Co-authored-by: Chris Rehn <1280602+hoffa@users.noreply.github.com> --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e1d7759943..40ad9b32a2 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ![Install](https://img.shields.io/badge/brew-aws--sam--cli-orange) ![pip](https://img.shields.io/badge/pip-aws--sam--cli-9cf) -[Installation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) | [Blogs](https://serverlessland.com/blog?tag=AWS%20SAM) | [Videos](https://serverlessland.com/video?tag=AWS%20SAM) | [AWS Docs](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) | [Roadmap](https://github.com/aws/aws-sam-cli/wiki/SAM-CLI-Roadmap) | [Try It Out](https://s12d.com/Tq9ZE-Br) +[Installation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) | [Blogs](https://serverlessland.com/blog?tag=AWS%20SAM) | [Videos](https://serverlessland.com/video?tag=AWS%20SAM) | [AWS Docs](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) | [Roadmap](https://github.com/aws/aws-sam-cli/wiki/SAM-CLI-Roadmap) | [Try It Out](https://s12d.com/jKo46elk) | [Slack Us](https://join.slack.com/t/awsdevelopers/shared_invite/zt-yryddays-C9fkWrmguDv0h2EEDzCqvw) The AWS Serverless Application Model (SAM) CLI is an open-source CLI tool that helps you develop serverless applications containing [Lambda functions](https://aws.amazon.com/lambda/), [Step Functions](https://aws.amazon.com/step-functions/), [API Gateway](https://aws.amazon.com/api-gateway/), [EventBridge](https://aws.amazon.com/eventbridge/), [SQS](https://aws.amazon.com/sqs/), [SNS](https://aws.amazon.com/sns/) and more. Some of the features it provides are: - **Initialize serverless applications** in minutes with AWS-provided infrastructure templates with `sam init` @@ -28,10 +28,13 @@ The AWS Serverless Application Model (SAM) CLI is an open-source CLI tool that h * **Speed up development with SAM Accelerate** - quickly test your changes in the cloud. [Read docs here](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/accelerate.html). +* **The Complete SAM Workshop**- [This workshop](https://s12d.com/jKo46elk) is a great way to experience the power of SAM and SAM CLI. + * **Getting started with CI/CD? SAM pipelines can help you get started** - [This workshop](https://s12d.com/_JQ48d5T) walks you through the basics. * **Get started with Serverless Application development using SAM CLI** - [This workshop](https://s12d.com/Tq9ZE-Br) walks you through the basics. + ## Get Started To get started with building SAM-based applications, use the SAM CLI. SAM CLI provides a Lambda-like execution @@ -51,6 +54,7 @@ environment that lets you locally build, test, debug, and deploy [AWS serverless ## What is this Github repository? 💻 + This Github repository contains source code for SAM CLI. Here is the development team talking about this code: > SAM CLI code is written in Python. Source code is well documented, very modular, with 95% unit test coverage. @@ -59,6 +63,7 @@ We think you'll like the code base. Clone it and run `make pr` or `./Make -pr` o ## Related Repositories and Resources + + **SAM Transform** [Open source template specification](https://github.com/awslabs/serverless-application-model/) that provides shorthand syntax for CloudFormation + **SAM CLI application templates** Get started quickly with [predefined application templates](https://github.com/aws/aws-sam-cli-app-templates/blob/master/README.md) for all supported runtimes and languages, used by `sam init` + **Lambda Builders** [Lambda builder tools](https://github.com/aws/aws-lambda-builders) for supported runtimes and custom build workflows, used by `sam build` @@ -93,5 +98,7 @@ Source code is located on Github at [awsdocs/aws-sam-developer-guide](https://gi Read the [SAM Documentation Contribution Guide](https://github.com/awsdocs/aws-sam-developer-guide/blob/master/CONTRIBUTING.md) to get started. + ### Join the SAM Community on Slack + [Join the SAM developers channel (#samdev)](https://join.slack.com/t/awsdevelopers/shared_invite/zt-yryddays-C9fkWrmguDv0h2EEDzCqvw) on Slack to collaborate with fellow community members and the AWS SAM team. From fa26bff1415485e3603f8f3d59ff1234af54c5b7 Mon Sep 17 00:00:00 2001 From: Christian Gaetano <95438786+christiangaetano@users.noreply.github.com> Date: Tue, 1 Nov 2022 17:02:53 -0700 Subject: [PATCH 05/14] Extract full file name from Dockerfile path (#4360) * Extract full file name from Dockerfile path Using `.name` here instead of `.stem` will ensure that the entire file name is returned including any and all extensions. * Add unit test for Dockerfile with extension * Add dockerfile extension integration test This test will verify that a function can be built and invoked when the Dockerfile contains a suffix/extension in the file name. Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> --- .../samlib/resource_metadata_normalizer.py | 2 +- tests/integration/buildcmd/test_build_cmd.py | 28 +++++++++++++++ .../PythonImage/Dockerfile.production | 15 ++++++++ .../test_resource_metadata_normalizer.py | 35 +++++++++++++++++++ 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 tests/integration/testdata/buildcmd/PythonImage/Dockerfile.production diff --git a/samcli/lib/samlib/resource_metadata_normalizer.py b/samcli/lib/samlib/resource_metadata_normalizer.py index 1ed5a43be1..995d67306e 100644 --- a/samcli/lib/samlib/resource_metadata_normalizer.py +++ b/samcli/lib/samlib/resource_metadata_normalizer.py @@ -186,7 +186,7 @@ def _extract_image_asset_metadata(metadata): """ asset_path = Path(metadata.get(ASSET_PATH_METADATA_KEY, "")) dockerfile_path = Path(metadata.get(ASSET_DOCKERFILE_PATH_KEY), "") - dockerfile, path_from_asset = dockerfile_path.stem, dockerfile_path.parent + dockerfile, path_from_asset = dockerfile_path.name, dockerfile_path.parent dockerfile_context = str(Path(asset_path.joinpath(path_from_asset))) return { SAM_METADATA_DOCKERFILE_KEY: dockerfile, diff --git a/tests/integration/buildcmd/test_build_cmd.py b/tests/integration/buildcmd/test_build_cmd.py index c5afc184e8..683972e07a 100644 --- a/tests/integration/buildcmd/test_build_cmd.py +++ b/tests/integration/buildcmd/test_build_cmd.py @@ -86,6 +86,34 @@ def test_with_default_requirements(self, runtime, use_container): self.built_template, self.FUNCTION_LOGICAL_ID_IMAGE, self._make_parameter_override_arg(overrides), expected ) + @parameterized.expand([("3.6", False), ("3.7", False), ("3.8", False), ("3.9", False)]) + @pytest.mark.flaky(reruns=3) + def test_with_dockerfile_extension(self, runtime, use_container): + _tag = f"{random.randint(1,100)}" + overrides = { + "Runtime": runtime, + "Handler": "main.handler", + "DockerFile": "Dockerfile.production", + "Tag": _tag, + } + cmdlist = self.get_command_list(use_container=use_container, parameter_overrides=overrides) + + LOG.info("Running Command: ") + LOG.info(cmdlist) + run_command(cmdlist, cwd=self.working_dir) + + self._verify_image_build_artifact( + self.built_template, + self.FUNCTION_LOGICAL_ID_IMAGE, + "ImageUri", + f"{self.FUNCTION_LOGICAL_ID_IMAGE.lower()}:{_tag}", + ) + + expected = {"pi": "3.14"} + self._verify_invoke_built_function( + self.built_template, self.FUNCTION_LOGICAL_ID_IMAGE, self._make_parameter_override_arg(overrides), expected + ) + @pytest.mark.flaky(reruns=3) def test_intermediate_container_deleted(self): _tag = f"{random.randint(1, 100)}" diff --git a/tests/integration/testdata/buildcmd/PythonImage/Dockerfile.production b/tests/integration/testdata/buildcmd/PythonImage/Dockerfile.production new file mode 100644 index 0000000000..bd617ce1f0 --- /dev/null +++ b/tests/integration/testdata/buildcmd/PythonImage/Dockerfile.production @@ -0,0 +1,15 @@ +ARG BASE_RUNTIME + +FROM public.ecr.aws/lambda/python:$BASE_RUNTIME + +ARG FUNCTION_DIR="/var/task" + +RUN mkdir -p $FUNCTION_DIR + +COPY main.py $FUNCTION_DIR + +COPY __init__.py $FUNCTION_DIR +COPY requirements.txt $FUNCTION_DIR + +RUN python -m pip install -r $FUNCTION_DIR/requirements.txt -t $FUNCTION_DIR + diff --git a/tests/unit/lib/samlib/test_resource_metadata_normalizer.py b/tests/unit/lib/samlib/test_resource_metadata_normalizer.py index c4c0c2e877..5600fbc507 100644 --- a/tests/unit/lib/samlib/test_resource_metadata_normalizer.py +++ b/tests/unit/lib/samlib/test_resource_metadata_normalizer.py @@ -112,6 +112,41 @@ def test_replace_all_resources_that_contain_image_metadata(self): self.assertEqual(docker_build_args, template_data["Resources"]["Function1"]["Metadata"]["DockerBuildArgs"]) self.assertEqual("Function1", template_data["Resources"]["Function1"]["Metadata"]["SamResourceId"]) + def test_replace_all_resources_that_contain_image_metadata_dockerfile_extensions(self): + docker_build_args = {"arg1": "val1", "arg2": "val2"} + asset_path = pathlib.Path("/path", "to", "asset") + dockerfile_path = pathlib.Path("path", "to", "Dockerfile.production") + template_data = { + "Resources": { + "Function1": { + "Properties": { + "Code": { + "ImageUri": { + "Fn::Sub": "${AWS::AccountId}.dkr.ecr.${AWS::Region}.${AWS::URLSuffix}/cdk-hnb659fds-container-assets-${AWS::AccountId}-${AWS::Region}:b5d75370ccc2882b90f701c8f98952aae957e85e1928adac8860222960209056" + } + } + }, + "Metadata": { + "aws:asset:path": asset_path, + "aws:asset:property": "Code.ImageUri", + "aws:asset:dockerfile-path": dockerfile_path, + "aws:asset:docker-build-args": docker_build_args, + }, + }, + } + } + + ResourceMetadataNormalizer.normalize(template_data) + + expected_docker_context_path = str(pathlib.Path("/path", "to", "asset", "path", "to")) + self.assertEqual("function1", template_data["Resources"]["Function1"]["Properties"]["Code"]["ImageUri"]) + self.assertEqual( + expected_docker_context_path, template_data["Resources"]["Function1"]["Metadata"]["DockerContext"] + ) + self.assertEqual("Dockerfile.production", template_data["Resources"]["Function1"]["Metadata"]["Dockerfile"]) + self.assertEqual(docker_build_args, template_data["Resources"]["Function1"]["Metadata"]["DockerBuildArgs"]) + self.assertEqual("Function1", template_data["Resources"]["Function1"]["Metadata"]["SamResourceId"]) + def test_replace_all_resources_that_contain_image_metadata_windows_paths(self): docker_build_args = {"arg1": "val1", "arg2": "val2"} asset_path = "C:\\path\\to\\asset" From 0d77ac3b24b140de4527ca4b95650a1f0382d0c5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 2 Nov 2022 00:54:57 +0000 Subject: [PATCH 06/14] feat: updating app templates repo hash with (e3f10b90fbc696bb19e72957b5d05d186e4fa442) (#4372) Co-authored-by: GitHub Action --- samcli/runtime_config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samcli/runtime_config.json b/samcli/runtime_config.json index 4e0c556573..d69a1a4550 100644 --- a/samcli/runtime_config.json +++ b/samcli/runtime_config.json @@ -1,3 +1,3 @@ { - "app_template_repo_commit": "092491a3e1b4b084be0b78f66fc6a77fc778a709" + "app_template_repo_commit": "e3f10b90fbc696bb19e72957b5d05d186e4fa442" } From a97a7d7098a4474f36f944d25b1f9349d814c352 Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Wed, 2 Nov 2022 14:06:23 -0700 Subject: [PATCH 07/14] Update aws-sam-cli-bot as user for internal pr labels (#4376) --- .github/workflows/pr-labeler.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml index f6389b8abc..5c245b3d5d 100644 --- a/.github/workflows/pr-labeler.yml +++ b/.github/workflows/pr-labeler.yml @@ -21,7 +21,12 @@ jobs: with: github-token: ${{secrets.GITHUB_TOKEN}} script: | - const maintainers = ['jfuss', 'hoffa', 'awood45', 'aahung', 'hawflau', 'mndeveci', 'ssenchenko', 'qingchm', 'moelasmar', 'xazhao', 'mildaniel', 'marekaiv', 'torresxb1', 'lucashuy', 'hnnasit', 'sriram-mv'] + const maintainers = [ + 'aws-sam-cli-bot', + 'jfuss', 'hoffa', 'awood45', 'aahung', 'hawflau', 'mndeveci', 'ssenchenko', + 'qingchm', 'moelasmar', 'xazhao', 'mildaniel', 'marekaiv', 'torresxb1', + 'lucashuy', 'hnnasit', 'sriram-mv' + ] if (maintainers.includes(context.payload.sender.login)) { github.rest.issues.addLabels({ issue_number: context.issue.number, From 57f631ecd30765792442d43f9a0b5a7a4495c802 Mon Sep 17 00:00:00 2001 From: aws-sam-cli-bot <46753707+aws-sam-cli-bot@users.noreply.github.com> Date: Wed, 2 Nov 2022 14:52:28 -0700 Subject: [PATCH 08/14] chore: Bump AWS Lambda Builders version to 1.21.0 (#4374) --- requirements/base.txt | 2 +- requirements/reproducible-linux.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements/base.txt b/requirements/base.txt index 0457cab1bf..74f91e31b6 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -14,7 +14,7 @@ docker~=4.2.0 dateparser~=1.0 requests==2.25.1 serverlessrepo==0.1.10 -aws_lambda_builders==1.20.0 +aws_lambda_builders==1.21.0 tomlkit==0.7.2 watchdog==2.1.2 pyopenssl==22.0.0 diff --git a/requirements/reproducible-linux.txt b/requirements/reproducible-linux.txt index 1af103b2df..04d359107a 100644 --- a/requirements/reproducible-linux.txt +++ b/requirements/reproducible-linux.txt @@ -12,9 +12,9 @@ attrs==20.3.0 \ --hash=sha256:31b2eced602aa8423c2aea9c76a724617ed67cf9513173fd3a4f03e3a929c7e6 \ --hash=sha256:832aa3cde19744e49938b91fea06d69ecb9e649c93ba974535d08ad92164f700 # via jsonschema -aws-lambda-builders==1.20.0 \ - --hash=sha256:71b8b2870e735a2e2ac0e59e84295aa967bc8bdb36515feec539b10df2314549 \ - --hash=sha256:7c78b9f81a75fae4af3cb958dc0b3b268c12ebe16c3aa5cfd93dcd0c05cefd23 +aws-lambda-builders==1.21.0 \ + --hash=sha256:77a21d3fa969119b9d05c2a18abd8dd10cff9ee8ba9793932fa00953cefbe4e1 \ + --hash=sha256:d79ae58b5d3961f9f55e6645c4759ad9f5455165fb6a7932bf10da39f6d275c0 # via aws-sam-cli (setup.py) aws-sam-translator==1.53.0 \ --hash=sha256:392ed4f5fb08f72cb68a8800f0bc278d2a3b6609bd1ac66bfcdeaaa94cdc18e5 \ From 339e8d6968a09df123df6745ebe458238843d904 Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Thu, 3 Nov 2022 13:30:43 -0700 Subject: [PATCH 09/14] Publish pytesttest reports as artifacts in canary jobs (#4333) * Publish junit xml reports as artifacts in canary jobs * output canary test reports with pytest-report-json --- appveyor-ubuntu.yml | 27 +++++++++++++++------------ appveyor-windows.yml | 24 ++++++++++++++---------- requirements/dev.txt | 1 + 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/appveyor-ubuntu.yml b/appveyor-ubuntu.yml index 25004f0a01..b8f6476e83 100644 --- a/appveyor-ubuntu.yml +++ b/appveyor-ubuntu.yml @@ -176,11 +176,11 @@ for: - "pip install -e \".[pre-dev]\"" - "pip install -e \".[dev]\"" - - sh: "pytest -vv tests/integration/buildcmd" + - sh: "pytest -vv tests/integration/buildcmd --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json" # Set JAVA_HOME to java11 - sh: "JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64" - - sh: "pytest -vv tests/integration/buildcmd/test_build_cmd.py -k test_building_java11_in_process" + - sh: "pytest -vv tests/integration/buildcmd/test_build_cmd.py -k test_building_java11_in_process --json-report --json-report-file=TEST_REPORT-integration-buildcmd-java11" # Integ testing deploy - @@ -191,7 +191,7 @@ for: test_script: - "pip install -e \".[dev]\"" - - sh: "pytest -vv tests/integration/deploy" + - sh: "pytest -vv tests/integration/deploy --json-report --json-report-file=TEST_REPORT-integration-deploy.json" # Integ testing package - @@ -202,7 +202,7 @@ for: test_script: - "pip install -e \".[dev]\"" - - sh: "pytest -vv tests/integration/package" + - sh: "pytest -vv tests/integration/package --json-report --json-report-file=TEST_REPORT-integration-package.json" # Integ testing delete - @@ -213,7 +213,7 @@ for: test_script: - "pip install -e \".[dev]\"" - - sh: "pytest -vv tests/integration/delete" + - sh: "pytest -vv tests/integration/delete --json-report --json-report-file=TEST_REPORT-integration-delete.json" # Integ testing sync - @@ -224,7 +224,7 @@ for: test_script: - "pip install -e \".[dev]\"" - - sh: "pytest -vv tests/integration/sync" + - sh: "pytest -vv tests/integration/sync --json-report --json-report-file=TEST_REPORT-integration-sync.json" # Integ testing local - @@ -239,7 +239,7 @@ for: - "pylint --rcfile .pylintrc samcli" - "pip install -e \".[dev]\"" - - sh: "pytest -vv tests/integration/local" + - sh: "pytest -vv tests/integration/local --json-report --json-report-file=TEST_REPORT-integration-local.json" # Other testing - @@ -255,15 +255,18 @@ for: # Dev Tests - "pip install -e \".[dev]\"" - - "pytest --cov samcli --cov-report term-missing --cov-fail-under 94 tests/unit" + - "pytest --cov samcli --cov-report term-missing --cov-fail-under 94 tests/unit --json-report --json-report-file=TEST_REPORT-unit.json" - "pylint --rcfile .pylintrc samcli" - "mypy setup.py samcli tests" - - "pytest -n 4 tests/functional" + - "pytest -n 4 tests/functional --json-report --json-report-file=TEST_REPORT-functional.json" - - sh: "pytest tests/integration --ignore=tests/integration/buildcmd --ignore=tests/integration/delete --ignore=tests/integration/deploy --ignore=tests/integration/package --ignore=tests/integration/sync --ignore=tests/integration/local" - - sh: "pytest -vv tests/regression" + - sh: "pytest tests/integration --ignore=tests/integration/buildcmd --ignore=tests/integration/delete --ignore=tests/integration/deploy --ignore=tests/integration/package --ignore=tests/integration/sync --ignore=tests/integration/local --json-report --json-report-file=TEST_REPORT-integration-others.json" + - sh: "pytest -vv tests/regression --json-report --json-report-file=TEST_REPORT-regression.json" - sh: "black --check setup.py tests samcli" # Smoke tests run in parallel - it runs on both Linux & Windows # Presence of the RUN_SMOKE envvar will run the smoke tests - - ps: "If ($env:RUN_SMOKE) {pytest -n 4 -vv tests/smoke}" \ No newline at end of file + - ps: "If ($env:RUN_SMOKE) {pytest -n 4 -vv tests/smoke --json-report --json-report-file=TEST_REPORT-smoke.json}" + +artifacts: + - path: './TEST_REPORT*.json' diff --git a/appveyor-windows.yml b/appveyor-windows.yml index 90d4e6c92f..d29e9c71a9 100644 --- a/appveyor-windows.yml +++ b/appveyor-windows.yml @@ -137,7 +137,7 @@ for: - "git --version" - "venv\\Scripts\\activate" - "docker system prune -a -f" - - ps: "pytest -vv tests/integration/buildcmd" + - ps: "pytest -vv tests/integration/buildcmd --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json" #Integ testing deploy - matrix: @@ -149,7 +149,7 @@ for: - "git --version" - "venv\\Scripts\\activate" - "docker system prune -a -f" - - ps: "pytest -vv tests/integration/deploy" + - ps: "pytest -vv tests/integration/deploy --json-report --json-report-file=TEST_REPORT-integration-deploy.json" # Integ testing package - matrix: @@ -161,7 +161,7 @@ for: - "git --version" - "venv\\Scripts\\activate" - "docker system prune -a -f" - - ps: "pytest -vv tests/integration/package" + - ps: "pytest -vv tests/integration/package --json-report --json-report-file=TEST_REPORT-integration-package.json" # Integ testing delete - matrix: @@ -173,7 +173,7 @@ for: - "git --version" - "venv\\Scripts\\activate" - "docker system prune -a -f" - - ps: "pytest -vv tests/integration/delete" + - ps: "pytest -vv tests/integration/delete --json-report --json-report-file=TEST_REPORT-integration-delete.json" # Integ testing sync - matrix: @@ -185,7 +185,7 @@ for: - "git --version" - "venv\\Scripts\\activate" - "docker system prune -a -f" - - ps: "pytest -vv tests/integration/sync" + - ps: "pytest -vv tests/integration/sync --json-report --json-report-file=TEST_REPORT-integration-sync.json" #Integ testing local - matrix: @@ -197,7 +197,7 @@ for: - "git --version" - "venv\\Scripts\\activate" - "docker system prune -a -f" - - ps: "pytest -vv tests/integration/local" + - ps: "pytest -vv tests/integration/local --json-report --json-report-file=TEST_REPORT-integration-local.json" #Other testing - matrix: @@ -209,11 +209,15 @@ for: - "git --version" - "venv\\Scripts\\activate" - "docker system prune -a -f" - - ps: "pytest --cov samcli --cov-report term-missing --cov-fail-under 94 tests/unit" + - ps: "pytest --cov samcli --cov-report term-missing --cov-fail-under 94 tests/unit --json-report --json-report-file=TEST_REPORT-unit.json" - "mypy setup.py samcli tests" - - ps: "pytest -n 4 tests/functional" - - ps: "pytest -vv tests/integration --ignore=tests/integration/buildcmd --ignore=tests/integration/delete --ignore=tests/integration/deploy --ignore=tests/integration/package --ignore=tests/integration/sync --ignore=tests/integration/local" - - ps: "pytest -vv tests/regression" + - ps: "pytest -n 4 tests/functional --json-report --json-report-file=TEST_REPORT-functional.json" + - ps: "pytest -vv tests/integration --ignore=tests/integration/buildcmd --ignore=tests/integration/delete --ignore=tests/integration/deploy --ignore=tests/integration/package --ignore=tests/integration/sync --ignore=tests/integration/local --json-report --json-report-file=TEST_REPORT-integration-others.json" + - ps: "pytest -vv tests/regression --json-report --json-report-file=TEST_REPORT-regression.json" # Uncomment for RDP # on_finish: # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + +artifacts: + - path: './TEST_REPORT*.json' + \ No newline at end of file diff --git a/requirements/dev.txt b/requirements/dev.txt index d5239ae3b9..937602691e 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -17,6 +17,7 @@ pytest-xdist==2.1.0 pytest-forked==1.3.0 pytest-timeout==1.4.2 pytest-rerunfailures==9.1.1 +pytest-json-report==1.5.0 # formatter black==22.6.0 From c29d13edeee314477ee6bae9cfcc796fdd8db1e0 Mon Sep 17 00:00:00 2001 From: i18n-tribe <62100288+i18n-tribe@users.noreply.github.com> Date: Fri, 4 Nov 2022 16:39:11 +0000 Subject: [PATCH 10/14] Use the same DockerContext and Dockerfile paths as the CDK is using (#4074) * Use the same DockerContext and Dockerfile paths as the CDK is using * Add tests to ensure `Dockerfile` can be a path to a docker file via subdirectories. This means images can share code more easily. * Add tests to ensure SAM supports CDK apps where Docker image asset `file` is a path to a docker file via subdirectories. * Fixed failing test after merge conflict with commit fa26bff1415485e3603f8f3d59ff1234af54c5b7 Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com> Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com> --- .../samlib/resource_metadata_normalizer.py | 6 +- .../cdk/test_sam_cdk_integration.py | 10 +++ .../src/main/java/com/myorg/JavaStack.java | 21 +++++ .../cdk_v1/python/python/python_stack.py | 34 +++++++- .../cdk_v1/typescript/lib/test-stack.ts | 25 ++++++ .../src/main/java/com/myorg/JavaStack.java | 22 +++++ .../cdk_v2/python/python/python_stack.py | 34 +++++++- .../cdk_v2/typescript/lib/test-stack.ts | 25 ++++++ .../Dockerfile | 16 ++++ .../DockerImageFunctionWithSharedCode/app.js | 24 ++++++ .../Dockerfile | 16 ++++ .../FunctionImageAssetWithSharedCode/app.js | 24 ++++++ .../ImagesWithSharedCode/SharedCode/shared.js | 4 + .../docker/ImagesWithSharedCode/package.json | 16 ++++ tests/integration/buildcmd/test_build_cmd.py | 84 +++++++++++++++++++ .../PythonImagesWithSharedCode/__init__.py | 0 .../feature_phi/Dockerfile | 17 ++++ .../feature_phi/__init__.py | 0 .../feature_phi/main.py | 5 ++ .../feature_pi/Dockerfile | 17 ++++ .../feature_pi/__init__.py | 0 .../feature_pi/main.py | 5 ++ .../requirements.txt | 7 ++ .../shared_code/__init__.py | 0 .../shared_code/numbers.py | 14 ++++ .../template_images_with_shared_code.yaml | 29 +++++++ .../test_resource_metadata_normalizer.py | 17 ++-- 27 files changed, 458 insertions(+), 14 deletions(-) create mode 100644 tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/DockerImageFunctionWithSharedCode/Dockerfile create mode 100644 tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/DockerImageFunctionWithSharedCode/app.js create mode 100644 tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/FunctionImageAssetWithSharedCode/Dockerfile create mode 100644 tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/FunctionImageAssetWithSharedCode/app.js create mode 100644 tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/SharedCode/shared.js create mode 100644 tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/package.json create mode 100644 tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/__init__.py create mode 100644 tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_phi/Dockerfile create mode 100644 tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_phi/__init__.py create mode 100644 tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_phi/main.py create mode 100644 tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_pi/Dockerfile create mode 100644 tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_pi/__init__.py create mode 100644 tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_pi/main.py create mode 100644 tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/requirements.txt create mode 100644 tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/shared_code/__init__.py create mode 100644 tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/shared_code/numbers.py create mode 100644 tests/integration/testdata/buildcmd/template_images_with_shared_code.yaml diff --git a/samcli/lib/samlib/resource_metadata_normalizer.py b/samcli/lib/samlib/resource_metadata_normalizer.py index 995d67306e..f5bd53cd49 100644 --- a/samcli/lib/samlib/resource_metadata_normalizer.py +++ b/samcli/lib/samlib/resource_metadata_normalizer.py @@ -186,11 +186,9 @@ def _extract_image_asset_metadata(metadata): """ asset_path = Path(metadata.get(ASSET_PATH_METADATA_KEY, "")) dockerfile_path = Path(metadata.get(ASSET_DOCKERFILE_PATH_KEY), "") - dockerfile, path_from_asset = dockerfile_path.name, dockerfile_path.parent - dockerfile_context = str(Path(asset_path.joinpath(path_from_asset))) return { - SAM_METADATA_DOCKERFILE_KEY: dockerfile, - SAM_METADATA_DOCKER_CONTEXT_KEY: dockerfile_context, + SAM_METADATA_DOCKERFILE_KEY: str(dockerfile_path), + SAM_METADATA_DOCKER_CONTEXT_KEY: str(asset_path), SAM_METADATA_DOCKER_BUILD_ARGS_KEY: metadata.get(ASSET_DOCKERFILE_BUILD_ARGS_KEY, {}), } diff --git a/tests/iac_integration/cdk/test_sam_cdk_integration.py b/tests/iac_integration/cdk/test_sam_cdk_integration.py index ad33718ed6..f6257f0da5 100644 --- a/tests/iac_integration/cdk/test_sam_cdk_integration.py +++ b/tests/iac_integration/cdk/test_sam_cdk_integration.py @@ -111,6 +111,16 @@ def random_port(): ("/restapis/normal/functionGoRuntime", "Hello World from function construct with go runtime"), ("/restapis/normal/dockerImageFunction", "Hello World from docker image function construct"), ("/restapis/normal/functionImageAsset", "Hello World from function construct with image asset"), + ( + "/restapis/normal/dockerImageFunctionWithSharedCode", + "Hello World from docker image function construct " + "with a Dockerfile that shares code with another Dockerfile", + ), + ( + "/restapis/normal/functionImageAssetWithSharedCode", + "Hello World from function construct with image asset " + "with a Dockerfile that shares code with another Dockerfile", + ), ] ) @pytest.mark.flaky(reruns=3) diff --git a/tests/iac_integration/cdk/testdata/cdk_v1/java/src/main/java/com/myorg/JavaStack.java b/tests/iac_integration/cdk/testdata/cdk_v1/java/src/main/java/com/myorg/JavaStack.java index 86889b8d15..62b6f40764 100644 --- a/tests/iac_integration/cdk/testdata/cdk_v1/java/src/main/java/com/myorg/JavaStack.java +++ b/tests/iac_integration/cdk/testdata/cdk_v1/java/src/main/java/com/myorg/JavaStack.java @@ -192,6 +192,23 @@ public JavaStack(final Construct scope, final String id, final StackProps props) .tracing(Tracing.ACTIVE) .build(); + // both ways work when 'file' is a path via subfolders to the Dockerfile + // this is useful when multiple docker images share some common code + DockerImageFunction dockerImageFunctionWithSharedCode = DockerImageFunction.Builder.create(this, "DockerImageFunctionWithSharedCode") + .code(DockerImageCode.fromImageAsset("../../src/docker/ImagesWithSharedCode", + AssetImageCodeProps.builder().file("DockerImageFunctionWithSharedCode/Dockerfile").build() + ) + ).tracing(Tracing.ACTIVE) + .build(); + + Function functionImageAssetWithSharedCode = Function.Builder.create(this, "FunctionImageAssetWithSharedCode") + .code(Code.fromAssetImage("../../src/docker/ImagesWithSharedCode", + AssetImageCodeProps.builder().file("FunctionImageAssetWithSharedCode/Dockerfile").build())) + .handler(Handler.FROM_IMAGE) + .runtime(Runtime.FROM_IMAGE) + .tracing(Tracing.ACTIVE) + .build(); + //Rest APIs // Spec Rest Api @@ -239,6 +256,10 @@ public JavaStack(final Construct scope, final String id, final StackProps props) .addMethod("GET", new LambdaIntegration(dockerImageFunction)); normalRootResource.addResource("functionImageAsset") .addMethod("GET", new LambdaIntegration(functionImageAsset)); + normalRootResource.addResource("dockerImageFunctionWithSharedCode") + .addMethod("GET", new LambdaIntegration(dockerImageFunctionWithSharedCode)); + normalRootResource.addResource("functionImageAssetWithSharedCode") + .addMethod("GET", new LambdaIntegration(functionImageAssetWithSharedCode)); // Nested Stack new NestedStack1(this, "NestedStack"); diff --git a/tests/iac_integration/cdk/testdata/cdk_v1/python/python/python_stack.py b/tests/iac_integration/cdk/testdata/cdk_v1/python/python/python_stack.py index 643313486a..c453a4eb79 100644 --- a/tests/iac_integration/cdk/testdata/cdk_v1/python/python/python_stack.py +++ b/tests/iac_integration/cdk/testdata/cdk_v1/python/python/python_stack.py @@ -217,7 +217,7 @@ def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None: self, "DockerImageFunction", code=lambda1.DockerImageCode.from_image_asset( - "../../src/docker/DockerImageFunctionConstruct", + directory="../../src/docker/DockerImageFunctionConstruct", file="Dockerfile", ), tracing=lambda1.Tracing.ACTIVE, @@ -228,7 +228,7 @@ def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None: self, "FunctionImageAsset", code=lambda1.Code.from_asset_image( - "../../src/docker/FunctionConstructWithImageAssetCode", + directory="../../src/docker/FunctionConstructWithImageAssetCode", file="Dockerfile", ), handler=lambda1.Handler.FROM_IMAGE, @@ -236,6 +236,30 @@ def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None: tracing=lambda1.Tracing.ACTIVE, ) + # both ways work when 'file' is a path via subfolders to the Dockerfile + # this is useful when multiple docker images share some common code + docker_image_function_with_shared_code = lambda1.DockerImageFunction( + self, + "DockerImageFunctionWithSharedCode", + code=lambda1.DockerImageCode.from_image_asset( + directory="../../src/docker/ImagesWithSharedCode", + file="DockerImageFunctionWithSharedCode/Dockerfile", + ), + tracing=lambda1.Tracing.ACTIVE, + ) + + function_image_asset_with_shared_code = lambda1.Function( + self, + "FunctionImageAssetWithSharedCode", + code=lambda1.Code.from_asset_image( + directory="../../src/docker/ImagesWithSharedCode", + file="FunctionImageAssetWithSharedCode/Dockerfile", + ), + handler=lambda1.Handler.FROM_IMAGE, + runtime=lambda1.Runtime.FROM_IMAGE, + tracing=lambda1.Tracing.ACTIVE, + ) + # Rest APIs # Spec Rest Api @@ -287,6 +311,12 @@ def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None: normal_root_resource.add_resource("functionImageAsset").add_method( "GET", LambdaIntegration(function_image_asset) ) + normal_root_resource.add_resource("dockerImageFunctionWithSharedCode").add_method( + "GET", LambdaIntegration(docker_image_function_with_shared_code) + ) + normal_root_resource.add_resource("functionImageAssetWithSharedCode").add_method( + "GET", LambdaIntegration(function_image_asset_with_shared_code) + ) # Nested Stack NestedStack1(self, "NestedStack") diff --git a/tests/iac_integration/cdk/testdata/cdk_v1/typescript/lib/test-stack.ts b/tests/iac_integration/cdk/testdata/cdk_v1/typescript/lib/test-stack.ts index 3850e0196b..fa500f5929 100644 --- a/tests/iac_integration/cdk/testdata/cdk_v1/typescript/lib/test-stack.ts +++ b/tests/iac_integration/cdk/testdata/cdk_v1/typescript/lib/test-stack.ts @@ -191,6 +191,25 @@ export class CDKSupportDemoRootStack extends cdk.Stack { tracing: lambda.Tracing.ACTIVE, }); + // both ways work when 'file' is a path via subfolders to the Dockerfile + // this is useful when multiple docker images share some common code + const dockerImageFunctionWithSharedCode = new lambda.DockerImageFunction(this, "DockerImageFunctionWithSharedCode", { + code: lambda.DockerImageCode.fromImageAsset("../../src/docker/ImagesWithSharedCode", { + file: "DockerImageFunctionWithSharedCode/Dockerfile", + }), + tracing: lambda.Tracing.ACTIVE, + }); + + // another way + const functionImageAssetWithSharedCode = new lambda.Function(this, "FunctionImageAssetWithSharedCode", { + code: lambda.Code.fromAssetImage("../../src/docker/ImagesWithSharedCode", { + file: "FunctionImageAssetWithSharedCode/Dockerfile", + }), + handler: lambda.Handler.FROM_IMAGE, + runtime: lambda.Runtime.FROM_IMAGE, + tracing: lambda.Tracing.ACTIVE, + }); + //Rest APIs @@ -246,6 +265,12 @@ export class CDKSupportDemoRootStack extends cdk.Stack { normalRootResource.addResource('functionImageAsset') .addMethod('GET', new LambdaIntegration(functionImageAsset)); + + normalRootResource.addResource('dockerImageFunctionWithSharedCode') + .addMethod('GET', new LambdaIntegration(dockerImageFunctionWithSharedCode)); + + normalRootResource.addResource('functionImageAssetWithSharedCode') + .addMethod('GET', new LambdaIntegration(functionImageAssetWithSharedCode)); // Nested Stack new NestedStack1(this, 'NestedStack' ,{}); diff --git a/tests/iac_integration/cdk/testdata/cdk_v2/java/src/main/java/com/myorg/JavaStack.java b/tests/iac_integration/cdk/testdata/cdk_v2/java/src/main/java/com/myorg/JavaStack.java index cd7252823a..38fd03a99a 100644 --- a/tests/iac_integration/cdk/testdata/cdk_v2/java/src/main/java/com/myorg/JavaStack.java +++ b/tests/iac_integration/cdk/testdata/cdk_v2/java/src/main/java/com/myorg/JavaStack.java @@ -193,6 +193,23 @@ public JavaStack(final Construct scope, final String id, final StackProps props) .tracing(Tracing.ACTIVE) .build(); + // both ways work when 'file' is a path via subfolders to the Dockerfile + // this is useful when multiple docker images share some common code + DockerImageFunction dockerImageFunctionWithSharedCode = DockerImageFunction.Builder.create(this, "DockerImageFunctionWithSharedCode") + .code(DockerImageCode.fromImageAsset("../../src/docker/ImagesWithSharedCode", + AssetImageCodeProps.builder().file("DockerImageFunctionWithSharedCode/Dockerfile").build() + ) + ).tracing(Tracing.ACTIVE) + .build(); + + Function functionImageAssetWithSharedCode = Function.Builder.create(this, "FunctionImageAssetWithSharedCode") + .code(Code.fromAssetImage("../../src/docker/ImagesWithSharedCode", + AssetImageCodeProps.builder().file("FunctionImageAssetWithSharedCode/Dockerfile").build())) + .handler(Handler.FROM_IMAGE) + .runtime(Runtime.FROM_IMAGE) + .tracing(Tracing.ACTIVE) + .build(); + //Rest APIs // Spec Rest Api @@ -240,6 +257,11 @@ public JavaStack(final Construct scope, final String id, final StackProps props) .addMethod("GET", new LambdaIntegration(dockerImageFunction)); normalRootResource.addResource("functionImageAsset") .addMethod("GET", new LambdaIntegration(functionImageAsset)); + normalRootResource.addResource("dockerImageFunctionWithSharedCode") + .addMethod("GET", new LambdaIntegration(dockerImageFunctionWithSharedCode)); + normalRootResource.addResource("functionImageAssetWithSharedCode") + .addMethod("GET", new LambdaIntegration(functionImageAssetWithSharedCode)); + // Nested Stack new NestedStack1(this, "NestedStack"); diff --git a/tests/iac_integration/cdk/testdata/cdk_v2/python/python/python_stack.py b/tests/iac_integration/cdk/testdata/cdk_v2/python/python/python_stack.py index 6bd63a6eb8..730613ca41 100644 --- a/tests/iac_integration/cdk/testdata/cdk_v2/python/python/python_stack.py +++ b/tests/iac_integration/cdk/testdata/cdk_v2/python/python/python_stack.py @@ -217,7 +217,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: self, "DockerImageFunction", code=lambda1.DockerImageCode.from_image_asset( - "../../src/docker/DockerImageFunctionConstruct", + directory="../../src/docker/DockerImageFunctionConstruct", file="Dockerfile", ), tracing=lambda1.Tracing.ACTIVE, @@ -228,7 +228,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: self, "FunctionImageAsset", code=lambda1.Code.from_asset_image( - "../../src/docker/FunctionConstructWithImageAssetCode", + directory="../../src/docker/FunctionConstructWithImageAssetCode", file="Dockerfile", ), handler=lambda1.Handler.FROM_IMAGE, @@ -236,6 +236,30 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: tracing=lambda1.Tracing.ACTIVE, ) + # both ways work when 'file' is a path via subfolders to the Dockerfile + # this is useful when multiple docker images share some common code + docker_image_function_with_shared_code = lambda1.DockerImageFunction( + self, + "DockerImageFunctionWithSharedCode", + code=lambda1.DockerImageCode.from_image_asset( + directory="../../src/docker/ImagesWithSharedCode", + file="DockerImageFunctionWithSharedCode/Dockerfile", + ), + tracing=lambda1.Tracing.ACTIVE, + ) + + function_image_asset_with_shared_code = lambda1.Function( + self, + "FunctionImageAssetWithSharedCode", + code=lambda1.Code.from_asset_image( + directory="../../src/docker/ImagesWithSharedCode", + file="FunctionImageAssetWithSharedCode/Dockerfile", + ), + handler=lambda1.Handler.FROM_IMAGE, + runtime=lambda1.Runtime.FROM_IMAGE, + tracing=lambda1.Tracing.ACTIVE, + ) + # Rest APIs # Spec Rest Api @@ -287,6 +311,12 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: normal_root_resource.add_resource("functionImageAsset").add_method( "GET", LambdaIntegration(function_image_asset) ) + normal_root_resource.add_resource("dockerImageFunctionWithSharedCode").add_method( + "GET", LambdaIntegration(docker_image_function_with_shared_code) + ) + normal_root_resource.add_resource("functionImageAssetWithSharedCode").add_method( + "GET", LambdaIntegration(function_image_asset_with_shared_code) + ) # Nested Stack NestedStack1(self, "NestedStack") diff --git a/tests/iac_integration/cdk/testdata/cdk_v2/typescript/lib/test-stack.ts b/tests/iac_integration/cdk/testdata/cdk_v2/typescript/lib/test-stack.ts index eabd9ede5d..2d88a8ad26 100644 --- a/tests/iac_integration/cdk/testdata/cdk_v2/typescript/lib/test-stack.ts +++ b/tests/iac_integration/cdk/testdata/cdk_v2/typescript/lib/test-stack.ts @@ -190,6 +190,25 @@ export class CDKSupportDemoRootStack extends cdk.Stack { tracing: lambda.Tracing.ACTIVE, }); + // both ways work when 'file' is a path via subfolders to the Dockerfile + // this is useful when multiple docker images share some common code + const dockerImageFunctionWithSharedCode = new lambda.DockerImageFunction(this, "DockerImageFunctionWithSharedCode", { + code: lambda.DockerImageCode.fromImageAsset("../../src/docker/ImagesWithSharedCode", { + file: "DockerImageFunctionWithSharedCode/Dockerfile", + }), + tracing: lambda.Tracing.ACTIVE, + }); + + // another way + const functionImageAssetWithSharedCode = new lambda.Function(this, "FunctionImageAssetWithSharedCode", { + code: lambda.Code.fromAssetImage("../../src/docker/ImagesWithSharedCode", { + file: "FunctionImageAssetWithSharedCode/Dockerfile", + }), + handler: lambda.Handler.FROM_IMAGE, + runtime: lambda.Runtime.FROM_IMAGE, + tracing: lambda.Tracing.ACTIVE, + }); + //Rest APIs @@ -246,6 +265,12 @@ export class CDKSupportDemoRootStack extends cdk.Stack { normalRootResource.addResource('functionImageAsset') .addMethod('GET', new LambdaIntegration(functionImageAsset)); + normalRootResource.addResource('dockerImageFunctionWithSharedCode') + .addMethod('GET', new LambdaIntegration(dockerImageFunctionWithSharedCode)); + + normalRootResource.addResource('functionImageAssetWithSharedCode') + .addMethod('GET', new LambdaIntegration(functionImageAssetWithSharedCode)); + // Nested Stack new NestedStack1(this, 'NestedStack' ,{}); } diff --git a/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/DockerImageFunctionWithSharedCode/Dockerfile b/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/DockerImageFunctionWithSharedCode/Dockerfile new file mode 100644 index 0000000000..a2c99c17fd --- /dev/null +++ b/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/DockerImageFunctionWithSharedCode/Dockerfile @@ -0,0 +1,16 @@ +FROM public.ecr.aws/lambda/nodejs:14 + +# Add the lambda handler for this feature +COPY DockerImageFunctionWithSharedCode/app.js ./ + +# Add the shared code +COPY SharedCode/ ./SharedCode + +# Add the shared dependencies +COPY package.json ./ + +# Install the dependencies +RUN npm install + +# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) +CMD [ "app.lambdaHandler" ] \ No newline at end of file diff --git a/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/DockerImageFunctionWithSharedCode/app.js b/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/DockerImageFunctionWithSharedCode/app.js new file mode 100644 index 0000000000..239c7bafad --- /dev/null +++ b/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/DockerImageFunctionWithSharedCode/app.js @@ -0,0 +1,24 @@ +var gen = require('unique-names-generator'); +const {sayHelloWorld} = require("./SharedCode/shared"); + +const colorName = gen.uniqueNamesGenerator({ + dictionaries: [gen.colors] +}); + + +exports.lambdaHandler = async(event, context) => { + let response; + + try { + response = { + 'statusCode': 200, + 'body': JSON.stringify({ + message: sayHelloWorld("docker image function construct"), + }), + }; + } catch (err) { + console.log(err); + return err; + } + return response; +}; diff --git a/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/FunctionImageAssetWithSharedCode/Dockerfile b/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/FunctionImageAssetWithSharedCode/Dockerfile new file mode 100644 index 0000000000..a68a4f5978 --- /dev/null +++ b/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/FunctionImageAssetWithSharedCode/Dockerfile @@ -0,0 +1,16 @@ +FROM public.ecr.aws/lambda/nodejs:14 + +# Add the lambda handler for this feature +COPY FunctionImageAssetWithSharedCode/app.js ./ + +# Add the shared code +COPY SharedCode/ ./SharedCode + +# Add the shared dependencies +COPY package.json ./ + +# Install the dependencies +RUN npm install + +# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) +CMD [ "app.lambdaHandler" ] \ No newline at end of file diff --git a/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/FunctionImageAssetWithSharedCode/app.js b/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/FunctionImageAssetWithSharedCode/app.js new file mode 100644 index 0000000000..f1dca39268 --- /dev/null +++ b/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/FunctionImageAssetWithSharedCode/app.js @@ -0,0 +1,24 @@ +var gen = require('unique-names-generator'); +const {sayHelloWorld} = require("./SharedCode/shared"); + +const colorName = gen.uniqueNamesGenerator({ + dictionaries: [gen.colors] +}); + + +exports.lambdaHandler = async(event, context) => { + let response; + + try { + response = { + 'statusCode': 200, + 'body': JSON.stringify({ + message: sayHelloWorld("function construct with image asset"), + }), + }; + } catch (err) { + console.log(err); + return err; + } + return response; +}; diff --git a/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/SharedCode/shared.js b/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/SharedCode/shared.js new file mode 100644 index 0000000000..334a8051fe --- /dev/null +++ b/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/SharedCode/shared.js @@ -0,0 +1,4 @@ + +exports.sayHelloWorld = (from) => { + return `Hello World from ${from} with a Dockerfile that shares code with another Dockerfile`; +} diff --git a/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/package.json b/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/package.json new file mode 100644 index 0000000000..7b15f7c978 --- /dev/null +++ b/tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/package.json @@ -0,0 +1,16 @@ +{ + "name": "randomColors", + "version": "0.1.0", + "bin": { + "randomColors": "bin/app.js" + }, + "scripts": { + "build": "tsc", + "watch": "tsc -w", + "test": "jest", + "cdk": "cdk" + }, + "dependencies": { + "unique-names-generator": "^4.6.0" + } +} diff --git a/tests/integration/buildcmd/test_build_cmd.py b/tests/integration/buildcmd/test_build_cmd.py index 683972e07a..8289dc741b 100644 --- a/tests/integration/buildcmd/test_build_cmd.py +++ b/tests/integration/buildcmd/test_build_cmd.py @@ -149,6 +149,90 @@ def test_intermediate_container_deleted(self): ) +@skipIf( + # Hits public ECR pull limitation, move it to canary tests + ((not RUN_BY_CANARY) or (IS_WINDOWS and RUNNING_ON_CI) and not CI_OVERRIDE), + "Skip build tests on windows when running in CI unless overridden", +) +class TestBuildCommand_PythonFunctions_ImagesWithSharedCode(BuildIntegBase): + template = "template_images_with_shared_code.yaml" + + EXPECTED_FILES_PROJECT_MANIFEST: Set[str] = set() + + FUNCTION_LOGICAL_ID_IMAGE = "ImageFunction" + + @parameterized.expand( + [ + *[(runtime, "feature_phi/Dockerfile", {"phi": "1.62"}) for runtime in ["3.6", "3.7", "3.8", "3.9"]], + *[(runtime, "feature_pi/Dockerfile", {"pi": "3.14"}) for runtime in ["3.6", "3.7", "3.8", "3.9"]], + ] + ) + @pytest.mark.flaky(reruns=3) + def test_with_default_requirements(self, runtime, dockerfile, expected): + _tag = f"{random.randint(1, 100)}" + overrides = { + "Runtime": runtime, + "Handler": "main.handler", + "DockerFile": dockerfile, + "Tag": _tag, + } + cmdlist = self.get_command_list(use_container=False, parameter_overrides=overrides) + + LOG.info("Running Command: ") + LOG.info(cmdlist) + run_command(cmdlist, cwd=self.working_dir) + + self._verify_image_build_artifact( + self.built_template, + self.FUNCTION_LOGICAL_ID_IMAGE, + "ImageUri", + f"{self.FUNCTION_LOGICAL_ID_IMAGE.lower()}:{_tag}", + ) + + self._verify_invoke_built_function( + self.built_template, self.FUNCTION_LOGICAL_ID_IMAGE, self._make_parameter_override_arg(overrides), expected + ) + + @parameterized.expand( + [ + ("feature_phi/Dockerfile", {"phi": "1.62"}), + ("feature_pi/Dockerfile", {"pi": "3.14"}), + ] + ) + @pytest.mark.flaky(reruns=3) + def test_intermediate_container_deleted(self, dockerfile, expected): + _tag = f"{random.randint(1, 100)}" + overrides = { + "Runtime": "3.9", + "Handler": "main.handler", + "DockerFile": dockerfile, + "Tag": _tag, + } + cmdlist = self.get_command_list(use_container=False, parameter_overrides=overrides) + + LOG.info("Running Command: ") + LOG.info(cmdlist) + + _num_of_containers_before_build = self.get_number_of_created_containers() + run_command(cmdlist, cwd=self.working_dir) + _num_of_containers_after_build = self.get_number_of_created_containers() + + self._verify_image_build_artifact( + self.built_template, + self.FUNCTION_LOGICAL_ID_IMAGE, + "ImageUri", + f"{self.FUNCTION_LOGICAL_ID_IMAGE.lower()}:{_tag}", + ) + + self._verify_invoke_built_function( + self.built_template, self.FUNCTION_LOGICAL_ID_IMAGE, self._make_parameter_override_arg(overrides), expected + ) + + self.assertEqual( + _num_of_containers_before_build, _num_of_containers_after_build, "Intermediate containers are not removed" + ) + + @skipIf( # Hits public ECR pull limitation, move it to canary tests ((not RUN_BY_CANARY) or (IS_WINDOWS and RUNNING_ON_CI) and not CI_OVERRIDE), diff --git a/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/__init__.py b/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_phi/Dockerfile b/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_phi/Dockerfile new file mode 100644 index 0000000000..dfa85dfdd0 --- /dev/null +++ b/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_phi/Dockerfile @@ -0,0 +1,17 @@ +ARG BASE_RUNTIME + +FROM public.ecr.aws/lambda/python:$BASE_RUNTIME + +ARG FUNCTION_DIR="/var/task" + +RUN mkdir -p $FUNCTION_DIR + +COPY feature_phi/__init__.py $FUNCTION_DIR +COPY feature_phi/main.py $FUNCTION_DIR + +COPY shared_code/ $FUNCTION_DIR/shared_code/ + +COPY requirements.txt $FUNCTION_DIR + +RUN python -m pip install -r $FUNCTION_DIR/requirements.txt -t $FUNCTION_DIR + diff --git a/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_phi/__init__.py b/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_phi/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_phi/main.py b/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_phi/main.py new file mode 100644 index 0000000000..f2bedbf9cc --- /dev/null +++ b/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_phi/main.py @@ -0,0 +1,5 @@ +from shared_code import numbers + + +def handler(event, context): + return {"phi": numbers.get_phi_2dp()} diff --git a/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_pi/Dockerfile b/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_pi/Dockerfile new file mode 100644 index 0000000000..9b5af1cda0 --- /dev/null +++ b/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_pi/Dockerfile @@ -0,0 +1,17 @@ +ARG BASE_RUNTIME + +FROM public.ecr.aws/lambda/python:$BASE_RUNTIME + +ARG FUNCTION_DIR="/var/task" + +RUN mkdir -p $FUNCTION_DIR + +COPY feature_pi/__init__.py $FUNCTION_DIR +COPY feature_pi/main.py $FUNCTION_DIR + +COPY shared_code/ $FUNCTION_DIR/shared_code/ + +COPY requirements.txt $FUNCTION_DIR + +RUN python -m pip install -r $FUNCTION_DIR/requirements.txt -t $FUNCTION_DIR + diff --git a/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_pi/__init__.py b/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_pi/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_pi/main.py b/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_pi/main.py new file mode 100644 index 0000000000..d0e5be035c --- /dev/null +++ b/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/feature_pi/main.py @@ -0,0 +1,5 @@ +from shared_code import numbers + + +def handler(event, context): + return {"pi": numbers.get_pi_2dp()} diff --git a/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/requirements.txt b/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/requirements.txt new file mode 100644 index 0000000000..ce4af48039 --- /dev/null +++ b/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/requirements.txt @@ -0,0 +1,7 @@ +# These are some hard packages to build. Using them here helps us verify that building works on various platforms + +# NOTE: Fixing to <1.20.3 as numpy1.20.3 started to use a new wheel naming convention (PEP 600) +numpy<1.20.3 +# `cryptography` has a dependency on `pycparser` which, for some reason doesn't build inside a Docker container. +# Turning this off until we resolve this issue: https://github.com/awslabs/aws-lambda-builders/issues/29 +# cryptography~=2.4 diff --git a/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/shared_code/__init__.py b/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/shared_code/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/shared_code/numbers.py b/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/shared_code/numbers.py new file mode 100644 index 0000000000..c1f999d1ea --- /dev/null +++ b/tests/integration/testdata/buildcmd/PythonImagesWithSharedCode/shared_code/numbers.py @@ -0,0 +1,14 @@ +import numpy + + +def _format_2dp(number): + return "{0:.2f}".format(number) + + +def get_pi_2dp(): + return _format_2dp(numpy.pi) + + +def get_phi_2dp(): + # Golden ratio + return _format_2dp((1 + 5 ** 0.5) / 2) diff --git a/tests/integration/testdata/buildcmd/template_images_with_shared_code.yaml b/tests/integration/testdata/buildcmd/template_images_with_shared_code.yaml new file mode 100644 index 0000000000..460d72176d --- /dev/null +++ b/tests/integration/testdata/buildcmd/template_images_with_shared_code.yaml @@ -0,0 +1,29 @@ +AWSTemplateFormatVersion : '2010-09-09' +Transform: AWS::Serverless-2016-10-31 + +Parameteres: + Runtime: + Type: String + DockerFile: + Type: String + Handler: + Type: String + Tag: + Type: String + +Resources: + + ImageFunction: + Type: AWS::Serverless::Function + Properties: + PackageType: Image + ImageConfig: + Command: + - !Ref Handler + Timeout: 600 + Metadata: + DockerTag: !Ref Tag + DockerContext: ./PythonImagesWithSharedCode + Dockerfile: !Ref DockerFile + DockerBuildArgs: + BASE_RUNTIME: !Ref Runtime diff --git a/tests/unit/lib/samlib/test_resource_metadata_normalizer.py b/tests/unit/lib/samlib/test_resource_metadata_normalizer.py index 5600fbc507..e027a527c4 100644 --- a/tests/unit/lib/samlib/test_resource_metadata_normalizer.py +++ b/tests/unit/lib/samlib/test_resource_metadata_normalizer.py @@ -103,12 +103,13 @@ def test_replace_all_resources_that_contain_image_metadata(self): ResourceMetadataNormalizer.normalize(template_data) - expected_docker_context_path = str(pathlib.Path("/path", "to", "asset", "path", "to")) + expected_docker_context_path = str(pathlib.Path("/path", "to", "asset")) self.assertEqual("function1", template_data["Resources"]["Function1"]["Properties"]["Code"]["ImageUri"]) self.assertEqual( expected_docker_context_path, template_data["Resources"]["Function1"]["Metadata"]["DockerContext"] ) - self.assertEqual("Dockerfile", template_data["Resources"]["Function1"]["Metadata"]["Dockerfile"]) + expected_dockerfile_path = str(pathlib.Path("path", "to", "Dockerfile")) + self.assertEqual(expected_dockerfile_path, template_data["Resources"]["Function1"]["Metadata"]["Dockerfile"]) self.assertEqual(docker_build_args, template_data["Resources"]["Function1"]["Metadata"]["DockerBuildArgs"]) self.assertEqual("Function1", template_data["Resources"]["Function1"]["Metadata"]["SamResourceId"]) @@ -138,12 +139,15 @@ def test_replace_all_resources_that_contain_image_metadata_dockerfile_extensions ResourceMetadataNormalizer.normalize(template_data) - expected_docker_context_path = str(pathlib.Path("/path", "to", "asset", "path", "to")) + expected_docker_context_path = str(pathlib.Path("/path", "to", "asset")) self.assertEqual("function1", template_data["Resources"]["Function1"]["Properties"]["Code"]["ImageUri"]) self.assertEqual( expected_docker_context_path, template_data["Resources"]["Function1"]["Metadata"]["DockerContext"] ) - self.assertEqual("Dockerfile.production", template_data["Resources"]["Function1"]["Metadata"]["Dockerfile"]) + self.assertEqual( + str(pathlib.Path("path/to/Dockerfile.production")), + template_data["Resources"]["Function1"]["Metadata"]["Dockerfile"], + ) self.assertEqual(docker_build_args, template_data["Resources"]["Function1"]["Metadata"]["DockerBuildArgs"]) self.assertEqual("Function1", template_data["Resources"]["Function1"]["Metadata"]["SamResourceId"]) @@ -173,12 +177,13 @@ def test_replace_all_resources_that_contain_image_metadata_windows_paths(self): ResourceMetadataNormalizer.normalize(template_data) - expected_docker_context_path = str(pathlib.Path("C:\\path\\to\\asset").joinpath(pathlib.Path("rel/path/to"))) + expected_docker_context_path = str(pathlib.Path("C:\\path\\to\\asset")) self.assertEqual("function1", template_data["Resources"]["Function1"]["Properties"]["Code"]["ImageUri"]) self.assertEqual( expected_docker_context_path, template_data["Resources"]["Function1"]["Metadata"]["DockerContext"] ) - self.assertEqual("Dockerfile", template_data["Resources"]["Function1"]["Metadata"]["Dockerfile"]) + expected_dockerfile_path = str(pathlib.Path("rel/path/to/Dockerfile")) + self.assertEqual(expected_dockerfile_path, template_data["Resources"]["Function1"]["Metadata"]["Dockerfile"]) self.assertEqual(docker_build_args, template_data["Resources"]["Function1"]["Metadata"]["DockerBuildArgs"]) self.assertEqual("Function1", template_data["Resources"]["Function1"]["Metadata"]["SamResourceId"]) From 4c3b4b53b459ccab8fc9048f3c045e3b18b7a68f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 7 Nov 2022 18:43:25 +0000 Subject: [PATCH 11/14] feat: updating app templates repo hash with (ef97aef12ebad99ffd8e14ed7abf9549007cb1aa) (#4381) Co-authored-by: GitHub Action --- samcli/runtime_config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samcli/runtime_config.json b/samcli/runtime_config.json index d69a1a4550..b3f22be06a 100644 --- a/samcli/runtime_config.json +++ b/samcli/runtime_config.json @@ -1,3 +1,3 @@ { - "app_template_repo_commit": "e3f10b90fbc696bb19e72957b5d05d186e4fa442" + "app_template_repo_commit": "1a9655d334bea4de48c611214d17b787d3ea4b3c" } From 3db6720763d86cdc99bfdca90eeaa23ca2f3c0c0 Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Tue, 8 Nov 2022 11:14:58 -0800 Subject: [PATCH 12/14] exclude installer dir in build (#4389) --- MANIFEST.in | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index a4857d6255..759f74d394 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,5 +5,6 @@ include requirements/pre-dev.txt include requirements/dev.txt recursive-include samcli * prune tests +prune installer global-exclude *.py[cod] global-exclude *.DS_Store diff --git a/setup.py b/setup.py index 9224bc32c2..75424aba52 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,7 @@ def read_version(): author_email="aws-sam-developers@amazon.com", url="https://github.com/awslabs/aws-sam-cli", license="Apache License 2.0", - packages=find_packages(exclude=["tests.*", "tests"]), + packages=find_packages(exclude=["tests.*", "tests", "installer.*", "installer"]), keywords="AWS SAM CLI", # Support Python 3.7 or greater python_requires=">=3.7, <=4.0, !=4.0", From 458076265651237a662a372f54d5b3df49fd6797 Mon Sep 17 00:00:00 2001 From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Date: Wed, 9 Nov 2022 17:05:43 -0800 Subject: [PATCH 13/14] chore: bump version to 1.62.0 (#4393) Co-authored-by: Lau --- samcli/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samcli/__init__.py b/samcli/__init__.py index 73d2d6f474..ff4ccb02c3 100644 --- a/samcli/__init__.py +++ b/samcli/__init__.py @@ -2,4 +2,4 @@ SAM CLI version """ -__version__ = "1.61.0" +__version__ = "1.62.0" From 76308076e5e312a88b3b159780b3adabbf27e1bd Mon Sep 17 00:00:00 2001 From: aws-sam-cli-bot <46753707+aws-sam-cli-bot@users.noreply.github.com> Date: Thu, 10 Nov 2022 12:41:29 -0800 Subject: [PATCH 14/14] chore: Bump SamTranslator version to 1.54.0 (#4402) --- requirements/base.txt | 2 +- requirements/reproducible-linux.txt | 8 +- .../validate/lib/models/alexa_skill.yaml | 3 +- .../lib/models/alexa_skill_with_skill_id.yaml | 2 + .../lib/models/all_policy_templates.yaml | 210 +++++++------- .../validate/lib/models/api_cache.yaml | 4 +- .../validate/lib/models/api_description.yaml | 2 + .../models/api_endpoint_configuration.yaml | 4 +- ...dpoint_configuration_with_vpcendpoint.yaml | 6 +- .../api_http_paths_with_if_condition.yaml | 50 ++-- ..._with_if_condition_no_value_else_case.yaml | 39 +-- ..._with_if_condition_no_value_then_case.yaml | 39 +-- .../lib/models/api_request_model.yaml | 4 +- .../models/api_request_model_openapi_3.yaml | 4 +- .../api_request_model_with_validator.yaml | 4 +- ...equest_model_with_validator_openapi_3.yaml | 4 +- ..._rest_paths_with_if_condition_openapi.yaml | 54 ++-- ..._condition_openapi_no_value_else_case.yaml | 43 ++- ..._condition_openapi_no_value_then_case.yaml | 43 ++- ..._rest_paths_with_if_condition_swagger.yaml | 54 ++-- ..._condition_swagger_no_value_else_case.yaml | 43 ++- ..._condition_swagger_no_value_then_case.yaml | 43 ++- ...integration_with_ref_intrinsic_api_id.yaml | 4 +- ...wagger_integration_with_string_api_id.yaml | 4 +- .../models/api_with_access_log_setting.yaml | 6 +- .../api_with_any_method_in_swagger.yaml | 10 +- .../api_with_apikey_default_override.yaml | 4 +- .../lib/models/api_with_apikey_required.yaml | 4 +- .../api_with_apikey_required_openapi_3.yaml | 7 +- .../lib/models/api_with_apikey_source.yaml | 6 +- .../lib/models/api_with_auth_all_maximum.yaml | 18 +- .../api_with_auth_all_maximum_openapi_3.yaml | 20 +- .../lib/models/api_with_auth_all_minimum.yaml | 20 +- .../api_with_auth_all_minimum_openapi.yaml | 20 +- .../api_with_auth_and_conditions_all_max.yaml | 24 +- .../lib/models/api_with_auth_no_default.yaml | 18 +- .../api_with_auth_with_default_scopes.yaml | 24 +- ...with_auth_with_default_scopes_openapi.yaml | 26 +- .../api_with_aws_account_blacklist.yaml | 3 +- .../api_with_aws_account_whitelist.yaml | 18 +- .../api_with_aws_iam_auth_overrides.yaml | 8 +- .../models/api_with_basic_custom_domain.yaml | 19 +- .../api_with_basic_custom_domain_http.yaml | 18 +- ...i_with_basic_custom_domain_intrinsics.yaml | 13 +- ...h_basic_custom_domain_intrinsics_http.yaml | 15 +- .../models/api_with_binary_media_types.yaml | 12 +- ...th_binary_media_types_definition_body.yaml | 17 +- .../lib/models/api_with_canary_setting.yaml | 6 +- .../validate/lib/models/api_with_cors.yaml | 53 +--- ..._with_cors_and_auth_no_preflight_auth.yaml | 10 +- ...api_with_cors_and_auth_preflight_auth.yaml | 8 +- ...cors_and_conditions_no_definitionbody.yaml | 8 +- ..._with_cors_and_only_credentials_false.yaml | 46 +--- .../api_with_cors_and_only_headers.yaml | 48 +--- .../models/api_with_cors_and_only_maxage.yaml | 46 +--- .../api_with_cors_and_only_methods.yaml | 5 +- .../api_with_cors_and_only_origins.yaml | 48 +--- .../api_with_cors_no_definitionbody.yaml | 6 +- .../lib/models/api_with_cors_openapi_3.yaml | 53 +--- .../api_with_custom_domain_route53.yaml | 12 +- ...ustom_domain_route53_hosted_zone_name.yaml | 12 +- ..._domain_route53_hosted_zone_name_http.yaml | 8 +- .../api_with_custom_domain_route53_http.yaml | 12 +- ...i_with_custom_domain_route53_multiple.yaml | 33 +-- ...ute53_multiple_intrinsic_hostedzoneid.yaml | 27 +- .../models/api_with_default_aws_iam_auth.yaml | 8 +- ...efault_aws_iam_auth_and_no_auth_route.yaml | 8 +- ...api_with_disable_api_execute_endpoint.yaml | 8 +- ...isable_api_execute_endpoint_openapi_3.yaml | 25 ++ .../lib/models/api_with_fail_on_warnings.yaml | 2 + .../models/api_with_gateway_responses.yaml | 2 + .../api_with_gateway_responses_all.yaml | 2 + ..._with_gateway_responses_all_openapi_3.yaml | 2 + .../api_with_gateway_responses_implicit.yaml | 6 +- .../api_with_gateway_responses_minimal.yaml | 2 + ..._gateway_responses_string_status_code.yaml | 2 + .../models/api_with_identity_intrinsic.yaml | 10 +- ...h_if_conditional_with_resource_policy.yaml | 22 +- .../api_with_incompatible_stage_name.yaml | 6 +- .../models/api_with_ip_range_blacklist.yaml | 4 +- .../models/api_with_ip_range_whitelist.yaml | 6 +- .../models/api_with_method_aws_iam_auth.yaml | 4 +- .../lib/models/api_with_method_settings.yaml | 18 +- .../api_with_minimum_compression_size.yaml | 2 + .../validate/lib/models/api_with_mode.yaml | 2 + .../lib/models/api_with_no_properties.yaml | 2 + .../lib/models/api_with_open_api_version.yaml | 2 + .../models/api_with_open_api_version_2.yaml | 2 + ..._with_openapi_definition_body_no_flag.yaml | 18 +- .../lib/models/api_with_path_parameters.yaml | 2 + .../lib/models/api_with_resource_policy.yaml | 9 +- .../api_with_resource_policy_global.yaml | 48 ++-- ..._with_resource_policy_global_implicit.yaml | 24 +- .../lib/models/api_with_resource_refs.yaml | 11 +- ...th_security_definition_and_components.yaml | 21 +- ...security_definition_and_no_components.yaml | 21 +- ...curity_definition_and_none_components.yaml | 21 +- .../models/api_with_source_vpc_blacklist.yaml | 5 +- .../models/api_with_source_vpc_whitelist.yaml | 9 +- .../lib/models/api_with_stage_tags.yaml | 20 +- ...pi_with_swagger_and_openapi_with_auth.yaml | 18 +- .../api_with_swagger_authorizer_none.yaml | 54 ++-- .../lib/models/api_with_usageplans.yaml | 259 +++++++++--------- .../api_with_usageplans_intrinsics.yaml | 136 ++++----- ...th_usageplans_shared_attributes_three.yaml | 12 +- ...with_usageplans_shared_attributes_two.yaml | 12 +- ...th_usageplans_shared_no_side_effect_1.yaml | 2 + ...th_usageplans_shared_no_side_effect_2.yaml | 2 + .../lib/models/api_with_xray_tracing.yaml | 2 + .../validate/lib/models/basic_function.yaml | 72 ++--- .../lib/models/basic_function_with_tags.yaml | 7 +- .../models/basic_function_withimageuri.yaml | 57 ++-- .../validate/lib/models/basic_layer.yaml | 32 ++- .../lib/models/cloudwatch_logs_with_ref.yaml | 7 +- .../validate/lib/models/cloudwatchevent.yaml | 8 +- .../models/cloudwatchevent_intrinsics.yaml | 20 +- .../validate/lib/models/cloudwatchlog.yaml | 5 +- .../models/cognito_userpool_with_event.yaml | 14 +- ...ngito_userpool_with_sms_configuration.yaml | 17 +- .../lib/models/connector_api_to_function.yaml | 38 +-- .../models/connector_bucket_to_function.yaml | 12 +- .../models/connector_dependson_replace.yaml | 86 ++++++ .../lib/models/connector_esm_dependson.yaml | 16 +- .../lib/models/connector_function_to_s3.yaml | 10 +- .../lib/models/connector_function_to_sqs.yaml | 30 +- .../models/connector_function_to_table.yaml | 32 ++- .../connector_hardcoded_lambda_arn.yaml | 4 +- .../lib/models/connector_hardcoded_props.yaml | 18 +- .../models/connector_hardcoded_rolename.yaml | 4 +- .../models/connector_rule_to_eventbus.yaml | 42 +-- .../lib/models/connector_rule_to_sfn.yaml | 32 ++- .../lib/models/connector_rule_to_sns.yaml | 28 +- .../lib/models/connector_sfn_to_function.yaml | 10 +- .../lib/models/connector_sfn_to_sfn.yaml | 74 ++++- .../lib/models/connector_sns_to_function.yaml | 20 +- .../lib/models/connector_sns_to_sqs.yaml | 24 +- .../lib/models/connector_sqs_to_function.yaml | 28 +- .../models/connector_table_to_function.yaml | 26 +- .../connector_table_to_function_read.yaml | 32 ++- .../definition_body_intrinsics_support.yaml | 115 ++++---- .../validate/lib/models/depends_on.yaml | 16 +- .../validate/lib/models/eventbridgerule.yaml | 8 +- .../eventbridgerule_schedule_properties.yaml | 10 +- .../lib/models/eventbridgerule_with_dlq.yaml | 22 +- .../eventbridgerule_with_retry_policy.yaml | 12 +- .../validate/lib/models/explicit_api.yaml | 6 +- .../lib/models/explicit_api_openapi_3.yaml | 6 +- ...plicit_api_with_invalid_events_config.yaml | 29 +- .../lib/models/explicit_http_api.yaml | 20 +- .../explicit_http_api_default_path.yaml | 47 ++++ .../lib/models/explicit_http_api_minimum.yaml | 4 +- .../lib/models/function_concurrency.yaml | 10 +- .../lib/models/function_event_conditions.yaml | 10 +- .../function_managed_inline_policy.yaml | 24 +- .../lib/models/function_with_alias.yaml | 5 +- .../function_with_alias_and_code_sha256.yaml | 9 +- ...function_with_alias_and_event_sources.yaml | 8 +- .../function_with_alias_intrinsics.yaml | 5 +- .../lib/models/function_with_amq.yaml | 10 +- .../lib/models/function_with_amq_kms.yaml | 12 +- .../models/function_with_architectures.yaml | 4 +- ...auth_mechanism_for_self_managed_kafka.yaml | 15 +- .../lib/models/function_with_condition.yaml | 12 +- ...ction_with_conditional_managed_policy.yaml | 13 +- ...ional_managed_policy_and_ref_no_value.yaml | 13 +- ...tion_with_conditional_policy_template.yaml | 17 +- ...onal_policy_template_and_ref_no_value.yaml | 15 +- ...stom_codedeploy_deployment_preference.yaml | 34 +-- ...onal_codedeploy_deployment_preference.yaml | 7 +- ...ction_with_deployment_and_custom_role.yaml | 9 +- ...ment_no_service_role_with_passthrough.yaml | 13 +- ...t_no_service_role_without_passthrough.yaml | 13 +- .../function_with_deployment_preference.yaml | 17 +- ...oyment_preference_alarms_intrinsic_if.yaml | 20 +- ..._deployment_preference_all_parameters.yaml | 40 +-- ...preference_condition_with_passthrough.yaml | 17 +- ...ference_condition_without_passthrough.yaml | 17 +- ...deployment_preference_from_parameters.yaml | 34 +-- ...ment_preference_multiple_combinations.yaml | 30 +- ...binations_conditions_with_passthrough.yaml | 30 +- ...ations_conditions_without_passthrough.yaml | 30 +- ...h_condition_with_supported_intrinsics.yaml | 66 ++--- ...n_with_disabled_deployment_preference.yaml | 6 +- .../function_with_disabled_traffic_hook.yaml | 9 +- .../lib/models/function_with_dlq.yaml | 4 +- .../function_with_ephemeral_storage.yaml | 12 +- ...function_with_event_bridge_rule_state.yaml | 14 +- .../lib/models/function_with_event_dest.yaml | 20 +- .../function_with_event_dest_basic.yaml | 4 +- .../function_with_event_dest_conditional.yaml | 11 +- .../models/function_with_event_filtering.yaml | 49 ++-- .../function_with_event_schedule_state.yaml | 38 ++- .../function_with_event_source_mapping.yaml | 18 +- .../function_with_file_system_config.yaml | 6 +- .../function_with_function_url_config.yaml | 29 +- ...ction_url_config_and_autopublishalias.yaml | 28 +- ...n_with_function_url_config_conditions.yaml | 33 +-- ...rl_config_with_iam_authorization_type.yaml | 29 +- ...h_function_url_config_with_intrinsics.yaml | 22 +- ...nction_url_config_without_cors_config.yaml | 3 +- .../models/function_with_global_layers.yaml | 15 +- .../function_with_intrinsic_architecture.yaml | 10 +- .../lib/models/function_with_kmskeyarn.yaml | 45 +-- .../lib/models/function_with_layers.yaml | 22 +- .../lib/models/function_with_many_layers.yaml | 16 +- .../models/function_with_mq_virtual_host.yaml | 14 +- .../lib/models/function_with_msk.yaml | 5 +- .../function_with_msk_with_intrinsics.yaml | 3 +- .../lib/models/function_with_null_events.yaml | 4 +- .../function_with_permissions_boundary.yaml | 5 +- .../function_with_policy_templates.yaml | 36 +-- .../function_with_request_parameters.yaml | 14 +- .../models/function_with_resource_refs.yaml | 13 +- .../function_with_self_managed_kafka.yaml | 23 +- .../models/function_with_signing_profile.yaml | 10 +- ..._with_sns_event_source_all_parameters.yaml | 8 +- ...vpc_permission_for_self_managed_kafka.yaml | 19 +- .../global_handle_path_level_parameter.yaml | 28 +- .../validate/lib/models/globals_for_api.yaml | 18 +- .../lib/models/globals_for_function.yaml | 23 +- .../lib/models/globals_for_simpletable.yaml | 4 +- .../lib/models/http_api_custom_iam_auth.yaml | 10 +- .../validate/lib/models/http_api_def_uri.yaml | 6 +- .../lib/models/http_api_description.yaml | 6 +- .../lib/models/http_api_existing_openapi.yaml | 33 +-- .../http_api_existing_openapi_conditions.yaml | 38 +-- .../lib/models/http_api_explicit_stage.yaml | 14 +- .../http_api_global_iam_auth_enabled.yaml | 2 + ..._with_existing_conflicting_authorizer.yaml | 10 +- .../lib/models/http_api_lambda_auth.yaml | 6 +- .../lib/models/http_api_lambda_auth_full.yaml | 14 +- .../http_api_local_iam_auth_enabled.yaml | 4 +- ..._with_existing_conflicting_authorizer.yaml | 10 +- .../models/http_api_multiple_authorizers.yaml | 10 +- .../lib/models/http_api_with_cors.yaml | 46 ++-- ...i_with_custom_domain_route53_multiple.yaml | 8 +- .../lib/models/http_api_with_null_path.yaml | 11 +- ...icit_and_explicit_api_with_conditions.yaml | 33 ++- .../validate/lib/models/implicit_api.yaml | 4 +- ...plicit_api_deletion_policy_precedence.yaml | 4 +- ...icit_api_with_auth_and_conditions_max.yaml | 40 +-- .../implicit_api_with_many_conditions.yaml | 90 +++--- ...api_with_serverless_rest_api_resource.yaml | 6 +- .../lib/models/implicit_http_api.yaml | 6 +- ...mplicit_http_api_auth_and_simple_case.yaml | 14 +- ...mplicit_http_api_with_many_conditions.yaml | 98 +++---- .../lib/models/inline_precedence.yaml | 4 +- .../lib/models/intrinsic_functions.yaml | 77 +++--- .../validate/lib/models/iot_rule.yaml | 3 +- .../lib/models/kinesis_intrinsics.yaml | 42 +-- .../layer_deletion_policy_precedence.yaml | 10 +- .../lib/models/layers_all_properties.yaml | 10 +- .../lib/models/layers_with_intrinsics.yaml | 25 +- ...i_with_custom_domain_route53_multiple.yaml | 12 +- ...api_with_serverless_rest_api_resource.yaml | 16 +- .../models/resource_with_invalid_type.yaml | 2 + .../commands/validate/lib/models/s3.yaml | 2 + .../validate/lib/models/s3_create_remove.yaml | 12 +- ...ing_lambda_notification_configuration.yaml | 2 + ...ting_other_notification_configuration.yaml | 2 + .../validate/lib/models/s3_filter.yaml | 2 + .../validate/lib/models/s3_intrinsics.yaml | 26 +- .../s3_multiple_events_same_bucket.yaml | 2 + .../lib/models/s3_multiple_functions.yaml | 2 + .../lib/models/s3_with_condition.yaml | 6 +- .../lib/models/s3_with_dependsOn.yaml | 2 + .../self_managed_kafka_with_intrinsics.yaml | 21 +- .../simple_table_ref_parameter_intrinsic.yaml | 8 +- .../models/simple_table_with_extra_tags.yaml | 18 +- .../models/simple_table_with_table_name.yaml | 10 +- .../validate/lib/models/simpletable.yaml | 6 +- .../lib/models/simpletable_with_sse.yaml | 8 +- .../commands/validate/lib/models/sns.yaml | 2 + .../sns_existing_other_subscription.yaml | 2 + .../validate/lib/models/sns_existing_sqs.yaml | 12 +- .../validate/lib/models/sns_intrinsics.yaml | 24 +- .../validate/lib/models/sns_outside_sqs.yaml | 10 +- .../commands/validate/lib/models/sns_sqs.yaml | 10 +- .../models/sns_topic_outside_template.yaml | 2 + .../commands/validate/lib/models/sqs.yaml | 4 +- ..._machine_with_api_auth_default_scopes.yaml | 32 ++- .../state_machine_with_api_authorizer.yaml | 14 +- ...e_machine_with_api_authorizer_maximum.yaml | 32 ++- ...tate_machine_with_api_resource_policy.yaml | 20 +- .../models/state_machine_with_condition.yaml | 8 +- ...ate_machine_with_condition_and_events.yaml | 12 +- .../lib/models/state_machine_with_cwe.yaml | 6 +- ...ate_machine_with_definition_S3_object.yaml | 14 +- ...ate_machine_with_definition_S3_string.yaml | 14 +- ...machine_with_definition_substitutions.yaml | 18 +- .../lib/models/state_machine_with_eb_dlq.yaml | 6 +- .../state_machine_with_eb_dlq_generated.yaml | 6 +- .../state_machine_with_eb_retry_policy.yaml | 6 +- ...ate_machine_with_event_schedule_state.yaml | 14 +- .../state_machine_with_explicit_api.yaml | 14 +- .../state_machine_with_express_logging.yaml | 48 ++-- .../state_machine_with_implicit_api.yaml | 12 +- ...ate_machine_with_implicit_api_globals.yaml | 14 +- .../state_machine_with_inline_definition.yaml | 12 +- ...ine_with_inline_definition_intrinsics.yaml | 14 +- .../state_machine_with_inline_policies.yaml | 14 +- .../state_machine_with_managed_policy.yaml | 4 +- .../state_machine_with_null_events.yaml | 6 +- ...ate_machine_with_permissions_boundary.yaml | 22 +- .../lib/models/state_machine_with_role.yaml | 2 + ...ate_machine_with_sam_policy_templates.yaml | 40 +-- .../models/state_machine_with_schedule.yaml | 33 ++- ...achine_with_schedule_dlq_retry_policy.yaml | 21 +- .../state_machine_with_standard_logging.yaml | 48 ++-- .../lib/models/state_machine_with_tags.yaml | 12 +- .../state_machine_with_xray_policies.yaml | 14 +- .../models/state_machine_with_xray_role.yaml | 2 + .../commands/validate/lib/models/streams.yaml | 10 +- .../models/translate_convert_metadata.yaml | 2 + .../lib/models/unsupported_resources.yaml | 2 + .../version_deletion_policy_precedence.yaml | 8 +- 316 files changed, 3332 insertions(+), 2769 deletions(-) create mode 100644 tests/functional/commands/validate/lib/models/api_with_disable_api_execute_endpoint_openapi_3.yaml create mode 100644 tests/functional/commands/validate/lib/models/connector_dependson_replace.yaml create mode 100644 tests/functional/commands/validate/lib/models/explicit_http_api_default_path.yaml diff --git a/requirements/base.txt b/requirements/base.txt index 74f91e31b6..6c594af2c3 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -8,7 +8,7 @@ boto3>=1.19.5,==1.* jmespath~=0.10.0 PyYAML~=5.3 cookiecutter~=2.1.1 -aws-sam-translator==1.53.0 +aws-sam-translator==1.54.0 #docker minor version updates can include breaking changes. Auto update micro version only. docker~=4.2.0 dateparser~=1.0 diff --git a/requirements/reproducible-linux.txt b/requirements/reproducible-linux.txt index 04d359107a..48fd602763 100644 --- a/requirements/reproducible-linux.txt +++ b/requirements/reproducible-linux.txt @@ -16,10 +16,10 @@ aws-lambda-builders==1.21.0 \ --hash=sha256:77a21d3fa969119b9d05c2a18abd8dd10cff9ee8ba9793932fa00953cefbe4e1 \ --hash=sha256:d79ae58b5d3961f9f55e6645c4759ad9f5455165fb6a7932bf10da39f6d275c0 # via aws-sam-cli (setup.py) -aws-sam-translator==1.53.0 \ - --hash=sha256:392ed4f5fb08f72cb68a8800f0bc278d2a3b6609bd1ac66bfcdeaaa94cdc18e5 \ - --hash=sha256:84d780ad82f1a176e2f5d4c397749d1e71214cc97ee7cccd50f823fd7c7e7cdf \ - --hash=sha256:85252646cf123642d08442137b60445e69e30bfd2f8b663b1202b20ab3782b10 +aws-sam-translator==1.54.0 \ + --hash=sha256:10d6771ebbe9107a0ddb756ccffd68ba81d885ef2eace80358a098566e6abaf1 \ + --hash=sha256:1bb4abb197e6de3f935425e65f67d14f47eb620d984e9de963b666cc9deb66e4 \ + --hash=sha256:a3ae79f1f2d430f5ade4d245165d5612414233f540b471d170f1aab95c3713a6 # via aws-sam-cli (setup.py) backports-zoneinfo==0.2.1 \ --hash=sha256:17746bd546106fa389c51dbea67c8b7c8f0d14b5526a579ca6ccf5ed72c526cf \ diff --git a/tests/functional/commands/validate/lib/models/alexa_skill.yaml b/tests/functional/commands/validate/lib/models/alexa_skill.yaml index b161c62818..f7de0a474d 100644 --- a/tests/functional/commands/validate/lib/models/alexa_skill.yaml +++ b/tests/functional/commands/validate/lib/models/alexa_skill.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- # File: sam.yml # Version: 0.9 @@ -16,4 +18,3 @@ Resources: MemorySize: 1024 Runtime: nodejs12.x Timeout: 3 - diff --git a/tests/functional/commands/validate/lib/models/alexa_skill_with_skill_id.yaml b/tests/functional/commands/validate/lib/models/alexa_skill_with_skill_id.yaml index cf6f00889b..c097d295d5 100644 --- a/tests/functional/commands/validate/lib/models/alexa_skill_with_skill_id.yaml +++ b/tests/functional/commands/validate/lib/models/alexa_skill_with_skill_id.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- # File: sam.yml # Version: 0.9 diff --git a/tests/functional/commands/validate/lib/models/all_policy_templates.yaml b/tests/functional/commands/validate/lib/models/all_policy_templates.yaml index c46cfaecb9..611a1bbaba 100644 --- a/tests/functional/commands/validate/lib/models/all_policy_templates.yaml +++ b/tests/functional/commands/validate/lib/models/all_policy_templates.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- # "Kitchen Sink" test containing all supported policy templates. The idea is to know every one of them is # transformable and fail on any changes in the policy template definition without updating the test # Since this not about testing the transformation logic, we will keep the policy template parameter values as literal @@ -5,172 +7,172 @@ Resources: KitchenSinkFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 Policies: - - SQSPollerPolicy: - QueueName: name + - SQSPollerPolicy: + QueueName: name - - LambdaInvokePolicy: - FunctionName: name + - LambdaInvokePolicy: + FunctionName: name - - CloudWatchDescribeAlarmHistoryPolicy: {} + - CloudWatchDescribeAlarmHistoryPolicy: {} - - CloudWatchPutMetricPolicy: {} + - CloudWatchPutMetricPolicy: {} - - EC2DescribePolicy: {} + - EC2DescribePolicy: {} - - DynamoDBCrudPolicy: - TableName: name + - DynamoDBCrudPolicy: + TableName: name - - DynamoDBReadPolicy: - TableName: name + - DynamoDBReadPolicy: + TableName: name - - SESSendBouncePolicy: - IdentityName: name + - SESSendBouncePolicy: + IdentityName: name - - ElasticsearchHttpPostPolicy: - DomainName: name + - ElasticsearchHttpPostPolicy: + DomainName: name - - S3ReadPolicy: - BucketName: name + - S3ReadPolicy: + BucketName: name - - S3CrudPolicy: - BucketName: name + - S3CrudPolicy: + BucketName: name - - AMIDescribePolicy: {} + - AMIDescribePolicy: {} - - CloudFormationDescribeStacksPolicy: {} + - CloudFormationDescribeStacksPolicy: {} - - RekognitionNoDataAccessPolicy: - CollectionId: id + - RekognitionNoDataAccessPolicy: + CollectionId: id - - RekognitionReadPolicy: - CollectionId: id + - RekognitionReadPolicy: + CollectionId: id - - RekognitionWriteOnlyAccessPolicy: - CollectionId: id + - RekognitionWriteOnlyAccessPolicy: + CollectionId: id - - SQSSendMessagePolicy: - QueueName: name + - SQSSendMessagePolicy: + QueueName: name - - SNSPublishMessagePolicy: - TopicName: name + - SNSPublishMessagePolicy: + TopicName: name - - VPCAccessPolicy: {} + - VPCAccessPolicy: {} - - DynamoDBStreamReadPolicy: - TableName: name - StreamName: name + - DynamoDBStreamReadPolicy: + TableName: name + StreamName: name - - KinesisStreamReadPolicy: - StreamName: name + - KinesisStreamReadPolicy: + StreamName: name - - SESCrudPolicy: - IdentityName: name + - SESCrudPolicy: + IdentityName: name - - SNSCrudPolicy: - TopicName: name + - SNSCrudPolicy: + TopicName: name - - KinesisCrudPolicy: - StreamName: name + - KinesisCrudPolicy: + StreamName: name - - KMSDecryptPolicy: - KeyId: keyId + - KMSDecryptPolicy: + KeyId: keyId - - PollyFullAccessPolicy: - LexiconName: name + - PollyFullAccessPolicy: + LexiconName: name - - S3FullAccessPolicy: - BucketName: name + - S3FullAccessPolicy: + BucketName: name - - CodePipelineLambdaExecutionPolicy: {} + - CodePipelineLambdaExecutionPolicy: {} - - ServerlessRepoReadWriteAccessPolicy: {} + - ServerlessRepoReadWriteAccessPolicy: {} - - EC2CopyImagePolicy: - ImageId: id + - EC2CopyImagePolicy: + ImageId: id - - CodePipelineReadOnlyPolicy: - PipelineName: pipeline + - CodePipelineReadOnlyPolicy: + PipelineName: pipeline - - CloudWatchDashboardPolicy: {} + - CloudWatchDashboardPolicy: {} - - RekognitionFacesPolicy: {} + - RekognitionFacesPolicy: {} - - RekognitionLabelsPolicy: {} + - RekognitionLabelsPolicy: {} - - DynamoDBBackupFullAccessPolicy: - TableName: table + - DynamoDBBackupFullAccessPolicy: + TableName: table - - DynamoDBRestoreFromBackupPolicy: - TableName: table + - DynamoDBRestoreFromBackupPolicy: + TableName: table - - ComprehendBasicAccessPolicy: {} + - ComprehendBasicAccessPolicy: {} - - AWSSecretsManagerRotationPolicy: - FunctionName: function + - AWSSecretsManagerRotationPolicy: + FunctionName: function - - MobileAnalyticsWriteOnlyAccessPolicy: {} + - MobileAnalyticsWriteOnlyAccessPolicy: {} - - PinpointEndpointAccessPolicy: - PinpointApplicationId: id + - PinpointEndpointAccessPolicy: + PinpointApplicationId: id - - RekognitionDetectOnlyPolicy: {} + - RekognitionDetectOnlyPolicy: {} - - RekognitionFacesManagementPolicy: - CollectionId: collection + - RekognitionFacesManagementPolicy: + CollectionId: collection - - EKSDescribePolicy: {} + - EKSDescribePolicy: {} - - CostExplorerReadOnlyPolicy: {} + - CostExplorerReadOnlyPolicy: {} - - OrganizationsListAccountsPolicy: {} + - OrganizationsListAccountsPolicy: {} - - DynamoDBReconfigurePolicy: - TableName: name + - DynamoDBReconfigurePolicy: + TableName: name - - SESBulkTemplatedCrudPolicy: - IdentityName: name + - SESBulkTemplatedCrudPolicy: + IdentityName: name - - SESEmailTemplateCrudPolicy: {} + - SESEmailTemplateCrudPolicy: {} - - FilterLogEventsPolicy: - LogGroupName: name + - FilterLogEventsPolicy: + LogGroupName: name - - SSMParameterReadPolicy: - ParameterName: name + - SSMParameterReadPolicy: + ParameterName: name - - StepFunctionsExecutionPolicy: - StateMachineName: name + - StepFunctionsExecutionPolicy: + StateMachineName: name - - CodeCommitCrudPolicy: - RepositoryName: name + - CodeCommitCrudPolicy: + RepositoryName: name - - CodeCommitReadPolicy: - RepositoryName: name + - CodeCommitReadPolicy: + RepositoryName: name - - KMSEncryptPolicy: - KeyId: keyId + - KMSEncryptPolicy: + KeyId: keyId - - AthenaQueryPolicy: - WorkGroupName: name + - AthenaQueryPolicy: + WorkGroupName: name - - S3WritePolicy: - BucketName: name + - S3WritePolicy: + BucketName: name - - DynamoDBWritePolicy: - TableName: name + - DynamoDBWritePolicy: + TableName: name - - EventBridgePutEventsPolicy: - EventBusName: name + - EventBridgePutEventsPolicy: + EventBusName: name - - AcmGetCertificatePolicy: - CertificateArn: arn + - AcmGetCertificatePolicy: + CertificateArn: arn - - Route53ChangeResourceRecordSetsPolicy: - HostedZoneId: test + - Route53ChangeResourceRecordSetsPolicy: + HostedZoneId: test diff --git a/tests/functional/commands/validate/lib/models/api_cache.yaml b/tests/functional/commands/validate/lib/models/api_cache.yaml index d94d72142e..789bec67e4 100644 --- a/tests/functional/commands/validate/lib/models/api_cache.yaml +++ b/tests/functional/commands/validate/lib/models/api_cache.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HtmlFunction: Type: AWS::Serverless::Function @@ -19,4 +21,4 @@ Resources: StageName: Prod DefinitionUri: s3://sam-demo-bucket/webpage_swagger.json CacheClusterEnabled: true - CacheClusterSize: "1.6" \ No newline at end of file + CacheClusterSize: '1.6' diff --git a/tests/functional/commands/validate/lib/models/api_description.yaml b/tests/functional/commands/validate/lib/models/api_description.yaml index c660e785e6..ed6355f5d8 100644 --- a/tests/functional/commands/validate/lib/models/api_description.yaml +++ b/tests/functional/commands/validate/lib/models/api_description.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: Function: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/api_endpoint_configuration.yaml b/tests/functional/commands/validate/lib/models/api_endpoint_configuration.yaml index bfe3ee901d..baca5a90d8 100644 --- a/tests/functional/commands/validate/lib/models/api_endpoint_configuration.yaml +++ b/tests/functional/commands/validate/lib/models/api_endpoint_configuration.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: EndpointConfig: Type: String @@ -5,7 +7,7 @@ Parameters: Globals: Api: # Overriding this property for Implicit API - EndpointConfiguration: { "Ref": "EndpointConfig" } + EndpointConfiguration: {Ref: EndpointConfig} Resources: ImplicitApiFunction: diff --git a/tests/functional/commands/validate/lib/models/api_endpoint_configuration_with_vpcendpoint.yaml b/tests/functional/commands/validate/lib/models/api_endpoint_configuration_with_vpcendpoint.yaml index ef735f2c58..a9e1ea7bcf 100644 --- a/tests/functional/commands/validate/lib/models/api_endpoint_configuration_with_vpcendpoint.yaml +++ b/tests/functional/commands/validate/lib/models/api_endpoint_configuration_with_vpcendpoint.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: EndpointConfigType: Type: String @@ -8,9 +10,9 @@ Globals: Api: # Overriding this property for Implicit API EndpointConfiguration: - Type: { "Ref": "EndpointConfigType" } + Type: {Ref: EndpointConfigType} VPCEndpointIds: - - { "Ref": "VpcEndpointId" } + - {Ref: VpcEndpointId} Resources: ImplicitApiFunction: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/api_http_paths_with_if_condition.yaml b/tests/functional/commands/validate/lib/models/api_http_paths_with_if_condition.yaml index 79fed2bba9..e8f5c1bded 100644 --- a/tests/functional/commands/validate/lib/models/api_http_paths_with_if_condition.yaml +++ b/tests/functional/commands/validate/lib/models/api_http_paths_with_if_condition.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > @@ -8,12 +10,12 @@ Description: > Conditions: TrueCondition: Fn::Equals: - - true - - true + - true + - true FalseCondition: Fn::Equals: - - true - - false + - true + - false Resources: MyAuthFn: @@ -29,17 +31,17 @@ Resources: Auth: Authorizers: MyLambdaAuthUpdated: - FunctionArn: + FunctionArn: Fn::GetAtt: - - MyAuthFn - - Arn + - MyAuthFn + - Arn FunctionInvokeRole: Fn::GetAtt: - - MyAuthFnRole - - Arn + - MyAuthFnRole + - Arn Identity: Headers: - - Authorization + - Authorization ReauthorizeEvery: 37 EnableSimpleResponses: false AuthorizerPayloadFormatVersion: 1.0 @@ -51,18 +53,16 @@ Resources: paths: /post: Fn::If: - - FalseCondition - - - post: - x-amazon-apigateway-integration: - httpMethod: POST - type: aws_proxy - uri: https://www.otherURI.co/ - payloadFormatVersion: '1.0' - - - post: - x-amazon-apigateway-integration: - httpMethod: POST - type: aws_proxy - uri: https://www.alphavantage.co/ - payloadFormatVersion: '1.0' \ No newline at end of file + - FalseCondition + - post: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: https://www.otherURI.co/ + payloadFormatVersion: '1.0' + - post: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: https://www.alphavantage.co/ + payloadFormatVersion: '1.0' diff --git a/tests/functional/commands/validate/lib/models/api_http_paths_with_if_condition_no_value_else_case.yaml b/tests/functional/commands/validate/lib/models/api_http_paths_with_if_condition_no_value_else_case.yaml index 822672b9df..ba5c6d2d0a 100644 --- a/tests/functional/commands/validate/lib/models/api_http_paths_with_if_condition_no_value_else_case.yaml +++ b/tests/functional/commands/validate/lib/models/api_http_paths_with_if_condition_no_value_else_case.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > @@ -8,12 +10,12 @@ Description: > Conditions: TrueCondition: Fn::Equals: - - true - - true + - true + - true FalseCondition: Fn::Equals: - - true - - false + - true + - false Resources: MyAuthFn: @@ -29,17 +31,17 @@ Resources: Auth: Authorizers: MyLambdaAuthUpdated: - FunctionArn: + FunctionArn: Fn::GetAtt: - - MyAuthFn - - Arn + - MyAuthFn + - Arn FunctionInvokeRole: Fn::GetAtt: - - MyAuthFnRole - - Arn + - MyAuthFnRole + - Arn Identity: Headers: - - Authorization + - Authorization ReauthorizeEvery: 37 EnableSimpleResponses: false AuthorizerPayloadFormatVersion: 1.0 @@ -51,12 +53,11 @@ Resources: paths: /post: Fn::If: - - FalseCondition - - - post: - x-amazon-apigateway-integration: - httpMethod: POST - type: aws_proxy - uri: https://www.alphavantage.co/ - payloadFormatVersion: '1.0' - - Ref: "AWS::NoValue" \ No newline at end of file + - FalseCondition + - post: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: https://www.alphavantage.co/ + payloadFormatVersion: '1.0' + - Ref: AWS::NoValue diff --git a/tests/functional/commands/validate/lib/models/api_http_paths_with_if_condition_no_value_then_case.yaml b/tests/functional/commands/validate/lib/models/api_http_paths_with_if_condition_no_value_then_case.yaml index 6bb4cf1459..13d618720d 100644 --- a/tests/functional/commands/validate/lib/models/api_http_paths_with_if_condition_no_value_then_case.yaml +++ b/tests/functional/commands/validate/lib/models/api_http_paths_with_if_condition_no_value_then_case.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > @@ -8,12 +10,12 @@ Description: > Conditions: TrueCondition: Fn::Equals: - - true - - true + - true + - true FalseCondition: Fn::Equals: - - true - - false + - true + - false Resources: MyAuthFn: @@ -29,17 +31,17 @@ Resources: Auth: Authorizers: MyLambdaAuthUpdated: - FunctionArn: + FunctionArn: Fn::GetAtt: - - MyAuthFn - - Arn + - MyAuthFn + - Arn FunctionInvokeRole: Fn::GetAtt: - - MyAuthFnRole - - Arn + - MyAuthFnRole + - Arn Identity: Headers: - - Authorization + - Authorization ReauthorizeEvery: 37 EnableSimpleResponses: false AuthorizerPayloadFormatVersion: 1.0 @@ -51,12 +53,11 @@ Resources: paths: /post: Fn::If: - - FalseCondition - - Ref: "AWS::NoValue" - - - post: - x-amazon-apigateway-integration: - httpMethod: POST - type: aws_proxy - uri: https://www.alphavantage.co/ - payloadFormatVersion: '1.0' \ No newline at end of file + - FalseCondition + - Ref: AWS::NoValue + - post: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: https://www.alphavantage.co/ + payloadFormatVersion: '1.0' diff --git a/tests/functional/commands/validate/lib/models/api_request_model.yaml b/tests/functional/commands/validate/lib/models/api_request_model.yaml index 5c1d96b073..ebc05600f4 100644 --- a/tests/functional/commands/validate/lib/models/api_request_model.yaml +++ b/tests/functional/commands/validate/lib/models/api_request_model.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HtmlFunction: Type: AWS::Serverless::Function @@ -34,4 +36,4 @@ Resources: type: object properties: username: - type: string \ No newline at end of file + type: string diff --git a/tests/functional/commands/validate/lib/models/api_request_model_openapi_3.yaml b/tests/functional/commands/validate/lib/models/api_request_model_openapi_3.yaml index 69e003ebdb..b27f842e03 100644 --- a/tests/functional/commands/validate/lib/models/api_request_model_openapi_3.yaml +++ b/tests/functional/commands/validate/lib/models/api_request_model_openapi_3.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HtmlFunction: Type: AWS::Serverless::Function @@ -51,4 +53,4 @@ Resources: type: object properties: username: - type: string \ No newline at end of file + type: string diff --git a/tests/functional/commands/validate/lib/models/api_request_model_with_validator.yaml b/tests/functional/commands/validate/lib/models/api_request_model_with_validator.yaml index 8c0f0629b8..ad1b8299e6 100644 --- a/tests/functional/commands/validate/lib/models/api_request_model_with_validator.yaml +++ b/tests/functional/commands/validate/lib/models/api_request_model_with_validator.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HtmlFunction: Type: AWS::Serverless::Function @@ -154,4 +156,4 @@ Resources: type: object properties: username: - type: string \ No newline at end of file + type: string diff --git a/tests/functional/commands/validate/lib/models/api_request_model_with_validator_openapi_3.yaml b/tests/functional/commands/validate/lib/models/api_request_model_with_validator_openapi_3.yaml index a7c2878492..0439c14276 100644 --- a/tests/functional/commands/validate/lib/models/api_request_model_with_validator_openapi_3.yaml +++ b/tests/functional/commands/validate/lib/models/api_request_model_with_validator_openapi_3.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HtmlFunction: Type: AWS::Serverless::Function @@ -29,4 +31,4 @@ Resources: type: object properties: username: - type: string \ No newline at end of file + type: string diff --git a/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_openapi.yaml b/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_openapi.yaml index facba27391..3f837995f2 100644 --- a/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_openapi.yaml +++ b/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_openapi.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > @@ -7,19 +9,17 @@ Description: > Globals: Api: - Cors: { - "Fn::Join": [",", ["www.amazon.com", "www.google.com"]] - } + Cors: {Fn::Join: [',', [www.amazon.com, www.google.com]]} Conditions: TrueCondition: Fn::Equals: - - true - - true + - true + - true FalseCondition: Fn::Equals: - - true - - false + - true + - false Resources: MyAuthFn: @@ -37,17 +37,17 @@ Resources: ApiKeyRequired: true Authorizers: MyLambdaAuthUpdated: - FunctionArn: + FunctionArn: Fn::GetAtt: - - MyAuthFn - - Arn + - MyAuthFn + - Arn FunctionInvokeRole: Fn::GetAtt: - - MyAuthFnRole - - Arn + - MyAuthFnRole + - Arn Identity: Headers: - - Authorization + - Authorization ReauthorizeEvery: 37 EnableSimpleResponses: false AuthorizerPayloadFormatVersion: 1.0 @@ -59,18 +59,16 @@ Resources: paths: /post: Fn::If: - - FalseCondition - - - post: - x-amazon-apigateway-integration: - httpMethod: POST - type: aws_proxy - uri: https://www.otherURI.co/ - payloadFormatVersion: '1.0' - - - post: - x-amazon-apigateway-integration: - httpMethod: POST - type: aws_proxy - uri: https://www.alphavantage.co/ - payloadFormatVersion: '1.0' \ No newline at end of file + - FalseCondition + - post: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: https://www.otherURI.co/ + payloadFormatVersion: '1.0' + - post: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: https://www.alphavantage.co/ + payloadFormatVersion: '1.0' diff --git a/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_openapi_no_value_else_case.yaml b/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_openapi_no_value_else_case.yaml index cef683a762..6399b678d0 100644 --- a/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_openapi_no_value_else_case.yaml +++ b/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_openapi_no_value_else_case.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > @@ -7,19 +9,17 @@ Description: > Globals: Api: - Cors: { - "Fn::Join": [",", ["www.amazon.com", "www.google.com"]] - } + Cors: {Fn::Join: [',', [www.amazon.com, www.google.com]]} Conditions: TrueCondition: Fn::Equals: - - true - - true + - true + - true FalseCondition: Fn::Equals: - - true - - false + - true + - false Resources: MyAuthFn: @@ -37,17 +37,17 @@ Resources: ApiKeyRequired: true Authorizers: MyLambdaAuthUpdated: - FunctionArn: + FunctionArn: Fn::GetAtt: - - MyAuthFn - - Arn + - MyAuthFn + - Arn FunctionInvokeRole: Fn::GetAtt: - - MyAuthFnRole - - Arn + - MyAuthFnRole + - Arn Identity: Headers: - - Authorization + - Authorization ReauthorizeEvery: 37 EnableSimpleResponses: false AuthorizerPayloadFormatVersion: 1.0 @@ -59,12 +59,11 @@ Resources: paths: /post: Fn::If: - - FalseCondition - - - post: - x-amazon-apigateway-integration: - httpMethod: POST - type: aws_proxy - uri: https://www.otherURI.co/ - payloadFormatVersion: '1.0' - - Ref: "AWS::NoValue" \ No newline at end of file + - FalseCondition + - post: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: https://www.otherURI.co/ + payloadFormatVersion: '1.0' + - Ref: AWS::NoValue diff --git a/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_openapi_no_value_then_case.yaml b/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_openapi_no_value_then_case.yaml index 9dc4719a8d..6444faf01f 100644 --- a/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_openapi_no_value_then_case.yaml +++ b/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_openapi_no_value_then_case.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > @@ -7,19 +9,17 @@ Description: > Globals: Api: - Cors: { - "Fn::Join": [",", ["www.amazon.com", "www.google.com"]] - } + Cors: {Fn::Join: [',', [www.amazon.com, www.google.com]]} Conditions: TrueCondition: Fn::Equals: - - true - - true + - true + - true FalseCondition: Fn::Equals: - - true - - false + - true + - false Resources: MyAuthFn: @@ -37,17 +37,17 @@ Resources: ApiKeyRequired: true Authorizers: MyLambdaAuthUpdated: - FunctionArn: + FunctionArn: Fn::GetAtt: - - MyAuthFn - - Arn + - MyAuthFn + - Arn FunctionInvokeRole: Fn::GetAtt: - - MyAuthFnRole - - Arn + - MyAuthFnRole + - Arn Identity: Headers: - - Authorization + - Authorization ReauthorizeEvery: 37 EnableSimpleResponses: false AuthorizerPayloadFormatVersion: 1.0 @@ -59,12 +59,11 @@ Resources: paths: /post: Fn::If: - - FalseCondition - - Ref: "AWS::NoValue" - - - post: - x-amazon-apigateway-integration: - httpMethod: POST - type: aws_proxy - uri: https://www.alphavantage.co/ - payloadFormatVersion: '1.0' \ No newline at end of file + - FalseCondition + - Ref: AWS::NoValue + - post: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: https://www.alphavantage.co/ + payloadFormatVersion: '1.0' diff --git a/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_swagger.yaml b/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_swagger.yaml index 8732c9ba13..54f9fbc432 100644 --- a/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_swagger.yaml +++ b/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_swagger.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > @@ -7,19 +9,17 @@ Description: > Globals: Api: - Cors: { - "Fn::Join": [",", ["www.amazon.com", "www.google.com"]] - } + Cors: {Fn::Join: [',', [www.amazon.com, www.google.com]]} Conditions: TrueCondition: Fn::Equals: - - true - - true + - true + - true FalseCondition: Fn::Equals: - - true - - false + - true + - false Resources: MyAuthFn: @@ -37,17 +37,17 @@ Resources: ApiKeyRequired: true Authorizers: MyLambdaAuthUpdated: - FunctionArn: + FunctionArn: Fn::GetAtt: - - MyAuthFn - - Arn + - MyAuthFn + - Arn FunctionInvokeRole: Fn::GetAtt: - - MyAuthFnRole - - Arn + - MyAuthFnRole + - Arn Identity: Headers: - - Authorization + - Authorization ReauthorizeEvery: 37 EnableSimpleResponses: false AuthorizerPayloadFormatVersion: 1.0 @@ -59,18 +59,16 @@ Resources: paths: /post: Fn::If: - - FalseCondition - - - post: - x-amazon-apigateway-integration: - httpMethod: POST - type: aws_proxy - uri: https://www.otherURI.co/ - payloadFormatVersion: '1.0' - - - post: - x-amazon-apigateway-integration: - httpMethod: POST - type: aws_proxy - uri: https://www.alphavantage.co/ - payloadFormatVersion: '1.0' \ No newline at end of file + - FalseCondition + - post: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: https://www.otherURI.co/ + payloadFormatVersion: '1.0' + - post: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: https://www.alphavantage.co/ + payloadFormatVersion: '1.0' diff --git a/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_swagger_no_value_else_case.yaml b/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_swagger_no_value_else_case.yaml index 32cf0c03c1..f271ba24cf 100644 --- a/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_swagger_no_value_else_case.yaml +++ b/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_swagger_no_value_else_case.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > @@ -7,19 +9,17 @@ Description: > Globals: Api: - Cors: { - "Fn::Join": [",", ["www.amazon.com", "www.google.com"]] - } + Cors: {Fn::Join: [',', [www.amazon.com, www.google.com]]} Conditions: TrueCondition: Fn::Equals: - - true - - true + - true + - true FalseCondition: Fn::Equals: - - true - - false + - true + - false Resources: MyAuthFn: @@ -37,17 +37,17 @@ Resources: ApiKeyRequired: true Authorizers: MyLambdaAuthUpdated: - FunctionArn: + FunctionArn: Fn::GetAtt: - - MyAuthFn - - Arn + - MyAuthFn + - Arn FunctionInvokeRole: Fn::GetAtt: - - MyAuthFnRole - - Arn + - MyAuthFnRole + - Arn Identity: Headers: - - Authorization + - Authorization ReauthorizeEvery: 37 EnableSimpleResponses: false AuthorizerPayloadFormatVersion: 1.0 @@ -59,12 +59,11 @@ Resources: paths: /post: Fn::If: - - FalseCondition - - - post: - x-amazon-apigateway-integration: - httpMethod: POST - type: aws_proxy - uri: https://www.otherURI.co/ - payloadFormatVersion: '1.0' - - Ref: "AWS::NoValue" \ No newline at end of file + - FalseCondition + - post: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: https://www.otherURI.co/ + payloadFormatVersion: '1.0' + - Ref: AWS::NoValue diff --git a/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_swagger_no_value_then_case.yaml b/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_swagger_no_value_then_case.yaml index 7f94cf1e59..db5822ea37 100644 --- a/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_swagger_no_value_then_case.yaml +++ b/tests/functional/commands/validate/lib/models/api_rest_paths_with_if_condition_swagger_no_value_then_case.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > @@ -7,19 +9,17 @@ Description: > Globals: Api: - Cors: { - "Fn::Join": [",", ["www.amazon.com", "www.google.com"]] - } + Cors: {Fn::Join: [',', [www.amazon.com, www.google.com]]} Conditions: TrueCondition: Fn::Equals: - - true - - true + - true + - true FalseCondition: Fn::Equals: - - true - - false + - true + - false Resources: MyAuthFn: @@ -37,17 +37,17 @@ Resources: ApiKeyRequired: true Authorizers: MyLambdaAuthUpdated: - FunctionArn: + FunctionArn: Fn::GetAtt: - - MyAuthFn - - Arn + - MyAuthFn + - Arn FunctionInvokeRole: Fn::GetAtt: - - MyAuthFnRole - - Arn + - MyAuthFnRole + - Arn Identity: Headers: - - Authorization + - Authorization ReauthorizeEvery: 37 EnableSimpleResponses: false AuthorizerPayloadFormatVersion: 1.0 @@ -59,12 +59,11 @@ Resources: paths: /post: Fn::If: - - FalseCondition - - Ref: "AWS::NoValue" - - - post: - x-amazon-apigateway-integration: - httpMethod: POST - type: aws_proxy - uri: https://www.alphavantage.co/ - payloadFormatVersion: '1.0' \ No newline at end of file + - FalseCondition + - Ref: AWS::NoValue + - post: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: https://www.alphavantage.co/ + payloadFormatVersion: '1.0' diff --git a/tests/functional/commands/validate/lib/models/api_swagger_integration_with_ref_intrinsic_api_id.yaml b/tests/functional/commands/validate/lib/models/api_swagger_integration_with_ref_intrinsic_api_id.yaml index c4f4a0503f..6558ee2dcf 100644 --- a/tests/functional/commands/validate/lib/models/api_swagger_integration_with_ref_intrinsic_api_id.yaml +++ b/tests/functional/commands/validate/lib/models/api_swagger_integration_with_ref_intrinsic_api_id.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HtmlFunction: Type: AWS::Serverless::Function @@ -21,4 +23,4 @@ Resources: HtmlApi: Type: AWS::Serverless::Api Properties: - StageName: Prod \ No newline at end of file + StageName: Prod diff --git a/tests/functional/commands/validate/lib/models/api_swagger_integration_with_string_api_id.yaml b/tests/functional/commands/validate/lib/models/api_swagger_integration_with_string_api_id.yaml index eb0f846da6..553b3337cc 100644 --- a/tests/functional/commands/validate/lib/models/api_swagger_integration_with_string_api_id.yaml +++ b/tests/functional/commands/validate/lib/models/api_swagger_integration_with_string_api_id.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HtmlFunction: Type: AWS::Serverless::Function @@ -20,4 +22,4 @@ Resources: HtmlApi: Type: AWS::Serverless::Api Properties: - StageName: Prod \ No newline at end of file + StageName: Prod diff --git a/tests/functional/commands/validate/lib/models/api_with_access_log_setting.yaml b/tests/functional/commands/validate/lib/models/api_with_access_log_setting.yaml index 5dc9b7bdba..4580310066 100644 --- a/tests/functional/commands/validate/lib/models/api_with_access_log_setting.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_access_log_setting.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- Globals: Api: AccessLogSetting: - DestinationArn: "arn:aws:logs:us-west-2:012345678901/API-Gateway-Execution-Logs_0123456789/prod:log-stream:12345678910" - Format: "$context.requestId" + DestinationArn: arn:aws:logs:us-west-2:012345678901/API-Gateway-Execution-Logs_0123456789/prod:log-stream:12345678910 + Format: $context.requestId Resources: ImplicitApiFunction: diff --git a/tests/functional/commands/validate/lib/models/api_with_any_method_in_swagger.yaml b/tests/functional/commands/validate/lib/models/api_with_any_method_in_swagger.yaml index bd6b304744..ae0b7b6639 100644 --- a/tests/functional/commands/validate/lib/models/api_with_any_method_in_swagger.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_any_method_in_swagger.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HttpApiFunction: Type: AWS::Serverless::Function @@ -23,13 +25,13 @@ Resources: StageName: Ref: Stage Auth: - DefaultAuthorizer: "LambdaAuthorizer" + DefaultAuthorizer: LambdaAuthorizer Authorizers: LambdaAuthorizer: - FunctionPayloadType: "REQUEST" + FunctionPayloadType: REQUEST Identity: Headers: - - "Authorization" + - Authorization DefinitionBody: openapi: '3.0' info: @@ -41,4 +43,4 @@ Resources: httpMethod: ANY type: http_proxy uri: https://www.alphavantage.co/ - payloadFormatVersion: '1.0' \ No newline at end of file + payloadFormatVersion: '1.0' diff --git a/tests/functional/commands/validate/lib/models/api_with_apikey_default_override.yaml b/tests/functional/commands/validate/lib/models/api_with_apikey_default_override.yaml index 51dd683e0a..9a4ce8f715 100644 --- a/tests/functional/commands/validate/lib/models/api_with_apikey_default_override.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_apikey_default_override.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyApiWithAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: diff --git a/tests/functional/commands/validate/lib/models/api_with_apikey_required.yaml b/tests/functional/commands/validate/lib/models/api_with_apikey_required.yaml index 27dfe9a720..188e0d2e9b 100644 --- a/tests/functional/commands/validate/lib/models/api_with_apikey_required.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_apikey_required.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyApiWithoutAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod diff --git a/tests/functional/commands/validate/lib/models/api_with_apikey_required_openapi_3.yaml b/tests/functional/commands/validate/lib/models/api_with_apikey_required_openapi_3.yaml index bd962b7709..16dfb82c20 100644 --- a/tests/functional/commands/validate/lib/models/api_with_apikey_required_openapi_3.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_apikey_required_openapi_3.yaml @@ -1,10 +1,11 @@ +%YAML 1.1 +--- Resources: MyApiWithoutAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod - OpenApiVersion: '3.0.1' - + OpenApiVersion: 3.0.1 MyFunctionWithApiKeyRequired: Type: AWS::Serverless::Function Properties: diff --git a/tests/functional/commands/validate/lib/models/api_with_apikey_source.yaml b/tests/functional/commands/validate/lib/models/api_with_apikey_source.yaml index d2b74e6042..cbdd00d72e 100644 --- a/tests/functional/commands/validate/lib/models/api_with_apikey_source.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_apikey_source.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyApiWithAuthSource: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -21,4 +23,4 @@ Resources: Path: /ApiKeyTrue Method: get Auth: - ApiKeyRequired: true \ No newline at end of file + ApiKeyRequired: true diff --git a/tests/functional/commands/validate/lib/models/api_with_auth_all_maximum.yaml b/tests/functional/commands/validate/lib/models/api_with_auth_all_maximum.yaml index 67e3f4a8eb..cd9d1febab 100644 --- a/tests/functional/commands/validate/lib/models/api_with_auth_all_maximum.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_auth_all_maximum.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyApi: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -15,8 +17,8 @@ Resources: MyCognitoAuthMultipleUserPools: UserPoolArn: - - arn:aws:2 - - arn:aws:3 + - arn:aws:2 + - arn:aws:3 Identity: Header: MyAuthorizationHeader2 ValidationExpression: myauthvalidationexpression2 @@ -42,13 +44,13 @@ Resources: FunctionInvokeRole: arn:aws:iam::123456789012:role/S3Access Identity: Headers: - - Authorization1 + - Authorization1 QueryStrings: - - Authorization2 + - Authorization2 StageVariables: - - Authorization3 + - Authorization3 Context: - - Authorization4 + - Authorization4 ReauthorizeEvery: 0 MyFunction: @@ -149,4 +151,4 @@ Resources: Properties: RestApiId: !Ref MyApi Path: /any/default - Method: any \ No newline at end of file + Method: any diff --git a/tests/functional/commands/validate/lib/models/api_with_auth_all_maximum_openapi_3.yaml b/tests/functional/commands/validate/lib/models/api_with_auth_all_maximum_openapi_3.yaml index 5c8d3597eb..0ac139a921 100644 --- a/tests/functional/commands/validate/lib/models/api_with_auth_all_maximum_openapi_3.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_auth_all_maximum_openapi_3.yaml @@ -1,9 +1,11 @@ +%YAML 1.1 +--- Resources: MyApi: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod - OpenApiVersion: '3.0.1' + OpenApiVersion: 3.0.1 Auth: DefaultAuthorizer: MyCognitoAuth ApiKeyRequired: true @@ -16,8 +18,8 @@ Resources: MyCognitoAuthMultipleUserPools: UserPoolArn: - - arn:aws:2 - - arn:aws:3 + - arn:aws:2 + - arn:aws:3 Identity: Header: MyAuthorizationHeader2 ValidationExpression: myauthvalidationexpression2 @@ -43,13 +45,13 @@ Resources: FunctionInvokeRole: arn:aws:iam::123456789012:role/S3Access Identity: Headers: - - Authorization1 + - Authorization1 QueryStrings: - - Authorization2 + - Authorization2 StageVariables: - - Authorization3 + - Authorization3 Context: - - Authorization4 + - Authorization4 ReauthorizeEvery: 0 MyFunction: @@ -150,4 +152,4 @@ Resources: Properties: RestApiId: !Ref MyApi Path: /any/default - Method: any \ No newline at end of file + Method: any diff --git a/tests/functional/commands/validate/lib/models/api_with_auth_all_minimum.yaml b/tests/functional/commands/validate/lib/models/api_with_auth_all_minimum.yaml index 5066b20d9b..e5e2e59038 100644 --- a/tests/functional/commands/validate/lib/models/api_with_auth_all_minimum.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_auth_all_minimum.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyApiWithCognitoAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -10,7 +12,7 @@ Resources: UserPoolArn: !GetAtt MyUserPool.Arn MyApiWithLambdaTokenAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -20,7 +22,7 @@ Resources: FunctionArn: !GetAtt MyAuthFn.Arn MyApiWithLambdaRequestAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -31,10 +33,10 @@ Resources: FunctionArn: !GetAtt MyAuthFn.Arn Identity: Headers: - - Authorization1 + - Authorization1 MyApiWithNotCachedLambdaRequestAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -110,8 +112,8 @@ Resources: PasswordPolicy: MinimumLength: 8 UsernameAttributes: - - email + - email Schema: - - AttributeDataType: String - Name: email - Required: false \ No newline at end of file + - AttributeDataType: String + Name: email + Required: false diff --git a/tests/functional/commands/validate/lib/models/api_with_auth_all_minimum_openapi.yaml b/tests/functional/commands/validate/lib/models/api_with_auth_all_minimum_openapi.yaml index bfa377bbbf..3b8018eef5 100644 --- a/tests/functional/commands/validate/lib/models/api_with_auth_all_minimum_openapi.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_auth_all_minimum_openapi.yaml @@ -1,9 +1,11 @@ +%YAML 1.1 +--- Globals: Api: - OpenApiVersion: '3.0.1' + OpenApiVersion: 3.0.1 Resources: MyApiWithCognitoAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -13,7 +15,7 @@ Resources: UserPoolArn: !GetAtt MyUserPool.Arn MyApiWithLambdaTokenAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -23,7 +25,7 @@ Resources: FunctionArn: !GetAtt MyAuthFn.Arn MyApiWithLambdaRequestAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -34,7 +36,7 @@ Resources: FunctionArn: !GetAtt MyAuthFn.Arn Identity: Headers: - - Authorization1 + - Authorization1 MyAuthFn: Type: AWS::Serverless::Function Properties: @@ -92,8 +94,8 @@ Resources: PasswordPolicy: MinimumLength: 8 UsernameAttributes: - - email + - email Schema: - - AttributeDataType: String - Name: email - Required: false \ No newline at end of file + - AttributeDataType: String + Name: email + Required: false diff --git a/tests/functional/commands/validate/lib/models/api_with_auth_and_conditions_all_max.yaml b/tests/functional/commands/validate/lib/models/api_with_auth_and_conditions_all_max.yaml index a2e5e12b47..2fe9a4e1a3 100644 --- a/tests/functional/commands/validate/lib/models/api_with_auth_and_conditions_all_max.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_auth_and_conditions_all_max.yaml @@ -1,11 +1,13 @@ +%YAML 1.1 +--- Conditions: PathCondition: Fn::Equals: - - true - - true + - true + - true Resources: MyApi: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -19,8 +21,8 @@ Resources: MyCognitoAuthMultipleUserPools: UserPoolArn: - - arn:aws:2 - - arn:aws:3 + - arn:aws:2 + - arn:aws:3 Identity: Header: MyAuthorizationHeader2 ValidationExpression: myauthvalidationexpression2 @@ -46,15 +48,15 @@ Resources: FunctionInvokeRole: arn:aws:iam::123456789012:role/S3Access Identity: Headers: - - Authorization1 + - Authorization1 QueryStrings: - - Authorization2 + - Authorization2 StageVariables: - - Authorization3 + - Authorization3 Context: - - Authorization4 + - Authorization4 ReauthorizeEvery: 0 - + MyFunction: Type: AWS::Serverless::Function Properties: @@ -116,4 +118,4 @@ Resources: Properties: RestApiId: !Ref MyApi Path: /users - Method: put \ No newline at end of file + Method: put diff --git a/tests/functional/commands/validate/lib/models/api_with_auth_no_default.yaml b/tests/functional/commands/validate/lib/models/api_with_auth_no_default.yaml index 3f3900386c..0125ab5bc8 100644 --- a/tests/functional/commands/validate/lib/models/api_with_auth_no_default.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_auth_no_default.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyApiWithCognitoAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -9,7 +11,7 @@ Resources: UserPoolArn: !GetAtt MyUserPool.Arn MyApiWithLambdaTokenAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -18,7 +20,7 @@ Resources: FunctionArn: !GetAtt MyAuthFn.Arn MyApiWithLambdaRequestAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -28,7 +30,7 @@ Resources: FunctionArn: !GetAtt MyAuthFn.Arn Identity: Headers: - - Authorization1 + - Authorization1 MyAuthFn: Type: AWS::Serverless::Function Properties: @@ -86,8 +88,8 @@ Resources: PasswordPolicy: MinimumLength: 8 UsernameAttributes: - - email + - email Schema: - - AttributeDataType: String - Name: email - Required: false \ No newline at end of file + - AttributeDataType: String + Name: email + Required: false diff --git a/tests/functional/commands/validate/lib/models/api_with_auth_with_default_scopes.yaml b/tests/functional/commands/validate/lib/models/api_with_auth_with_default_scopes.yaml index cd093a462a..cdf19eb83f 100644 --- a/tests/functional/commands/validate/lib/models/api_with_auth_with_default_scopes.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_auth_with_default_scopes.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyApiWithCognitoAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -9,13 +11,13 @@ Resources: MyDefaultCognitoAuth: UserPoolArn: arn:aws:1 AuthorizationScopes: - - default.write - - default.read + - default.write + - default.read MyCognitoAuthWithDefaultScopes: UserPoolArn: arn:aws:2 AuthorizationScopes: - - default.delete - - default.update + - default.delete + - default.update MyFn: Type: AWS::Serverless::Function @@ -54,9 +56,9 @@ Resources: Path: /cognitodefaultscopesoverwritten Auth: Authorizer: MyDefaultCognitoAuth - AuthorizationScopes: - - overwritten.read - - overwritten.write + AuthorizationScopes: + - overwritten.read + - overwritten.write CognitoAuthorizerScopesOverwritten: Type: Api Properties: @@ -65,9 +67,9 @@ Resources: Path: /cognitoauthorizercopesoverwritten Auth: Authorizer: MyCognitoAuthWithDefaultScopes - AuthorizationScopes: - - overwritten.read - - overwritten.write + AuthorizationScopes: + - overwritten.read + - overwritten.write CognitoDefaultScopesNone: Type: Api Properties: diff --git a/tests/functional/commands/validate/lib/models/api_with_auth_with_default_scopes_openapi.yaml b/tests/functional/commands/validate/lib/models/api_with_auth_with_default_scopes_openapi.yaml index 09031af777..e7ce488c50 100644 --- a/tests/functional/commands/validate/lib/models/api_with_auth_with_default_scopes_openapi.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_auth_with_default_scopes_openapi.yaml @@ -1,22 +1,24 @@ +%YAML 1.1 +--- Resources: MyApiWithCognitoAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod - OpenApiVersion: '3.0.1' + OpenApiVersion: 3.0.1 Auth: DefaultAuthorizer: MyDefaultCognitoAuth Authorizers: MyDefaultCognitoAuth: UserPoolArn: arn:aws:1 AuthorizationScopes: - - default.write - - default.read + - default.write + - default.read MyCognitoAuthWithDefaultScopes: UserPoolArn: arn:aws:2 AuthorizationScopes: - - default.delete - - default.update + - default.delete + - default.update MyFn: Type: AWS::Serverless::Function @@ -55,9 +57,9 @@ Resources: Path: /cognitodefaultscopesoverwritten Auth: Authorizer: MyDefaultCognitoAuth - AuthorizationScopes: - - overwritten.read - - overwritten.write + AuthorizationScopes: + - overwritten.read + - overwritten.write CognitoAuthorizerScopesOverwritten: Type: Api Properties: @@ -66,9 +68,9 @@ Resources: Path: /cognitoauthorizercopesoverwritten Auth: Authorizer: MyCognitoAuthWithDefaultScopes - AuthorizationScopes: - - overwritten.read - - overwritten.write + AuthorizationScopes: + - overwritten.read + - overwritten.write CognitoDefaultScopesNone: Type: Api Properties: diff --git a/tests/functional/commands/validate/lib/models/api_with_aws_account_blacklist.yaml b/tests/functional/commands/validate/lib/models/api_with_aws_account_blacklist.yaml index 19b51412a9..4078afb896 100644 --- a/tests/functional/commands/validate/lib/models/api_with_aws_account_blacklist.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_aws_account_blacklist.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: Api: Auth: @@ -28,4 +30,3 @@ Resources: Properties: Method: any Path: /any - diff --git a/tests/functional/commands/validate/lib/models/api_with_aws_account_whitelist.yaml b/tests/functional/commands/validate/lib/models/api_with_aws_account_whitelist.yaml index ff55cbae2b..5870f0c7e1 100644 --- a/tests/functional/commands/validate/lib/models/api_with_aws_account_whitelist.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_aws_account_whitelist.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: MyFunction: Type: AWS::Serverless::Function @@ -18,12 +20,8 @@ Resources: Properties: Auth: ResourcePolicy: - AwsAccountWhitelist: [ - "12345" - ] - AwsAccountBlacklist: [ - "67890" - ] + AwsAccountWhitelist: ['12345'] + AwsAccountBlacklist: ['67890'] Method: Put Path: /get Any: @@ -31,11 +29,7 @@ Resources: Properties: Auth: ResourcePolicy: - AwsAccountWhitelist: [ - "12345" - ] - AwsAccountBlacklist: [ - "67890" - ] + AwsAccountWhitelist: ['12345'] + AwsAccountBlacklist: ['67890'] Method: any Path: /any diff --git a/tests/functional/commands/validate/lib/models/api_with_aws_iam_auth_overrides.yaml b/tests/functional/commands/validate/lib/models/api_with_aws_iam_auth_overrides.yaml index c988dd0e3c..1e5ab4e886 100644 --- a/tests/functional/commands/validate/lib/models/api_with_aws_iam_auth_overrides.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_aws_iam_auth_overrides.yaml @@ -1,13 +1,15 @@ +%YAML 1.1 +--- Resources: MyApiWithAwsIamAuthNoCallerCredentials: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: DefaultAuthorizer: AWS_IAM InvokeRole: NONE MyApiWithAwsIamAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -122,7 +124,7 @@ Resources: Path: /MyFunctionNullInvokeRole Auth: Authorizer: AWS_IAM - InvokeRole: null + InvokeRole: MyFunctionCallerCredentialsOverride: Type: AWS::Serverless::Function Properties: diff --git a/tests/functional/commands/validate/lib/models/api_with_basic_custom_domain.yaml b/tests/functional/commands/validate/lib/models/api_with_basic_custom_domain.yaml index 2d8c915b09..9a244450ad 100644 --- a/tests/functional/commands/validate/lib/models/api_with_basic_custom_domain.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_basic_custom_domain.yaml @@ -1,9 +1,11 @@ +%YAML 1.1 +--- Parameters: - MyDomainName: + MyDomainName: Type: String Default: another-example.com - MyDomainCert: + MyDomainCert: Type: String Default: another-api-arn @@ -58,13 +60,13 @@ Resources: OpenApiVersion: 3.0.1 StageName: Prod Domain: - DomainName: 'api-example.com' - CertificateArn: 'my-api-cert-arn' - EndpointConfiguration: 'EDGE' - BasePath: [ "/get", "/fetch" ] + DomainName: api-example.com + CertificateArn: my-api-cert-arn + EndpointConfiguration: EDGE + BasePath: [/get, /fetch] MutualTlsAuthentication: - TruststoreUri: 'my-api-truststore-uri' - TruststoreVersion: 'my-api-truststore-version' + TruststoreUri: my-api-truststore-uri + TruststoreVersion: my-api-truststore-version SecurityPolicy: TLS_1_2 @@ -73,4 +75,3 @@ Resources: Properties: OpenApiVersion: 3.0.1 StageName: Prod - diff --git a/tests/functional/commands/validate/lib/models/api_with_basic_custom_domain_http.yaml b/tests/functional/commands/validate/lib/models/api_with_basic_custom_domain_http.yaml index 9172c00c11..a80c516109 100644 --- a/tests/functional/commands/validate/lib/models/api_with_basic_custom_domain_http.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_basic_custom_domain_http.yaml @@ -1,9 +1,11 @@ +%YAML 1.1 +--- Parameters: - MyDomainName: + MyDomainName: Type: String Default: sam-example.com - MyDomainCert: + MyDomainCert: Type: String Default: arn:aws:acm:us-east-1:123455353535:certificate/6c911401-620d-4d41-b89e-366c238bb2f3 @@ -14,16 +16,16 @@ Globals: CertificateArn: !Ref MyDomainCert EndpointConfiguration: REGIONAL MutualTlsAuthentication: - TruststoreUri: 'my-api-v2-truststore-uri' - TruststoreVersion: 'my-api-v2-truststore-version' + TruststoreUri: my-api-v2-truststore-uri + TruststoreVersion: my-api-v2-truststore-version SecurityPolicy: TLS_1_2 - BasePath: ["/basic", "/begin-here"] + BasePath: [/basic, /begin-here] Route53: HostedZoneName: sam-example.com. Resources: - HttpApiFunction: + HttpApiFunction: Type: AWS::Serverless::Function Properties: InlineCode: | @@ -47,9 +49,9 @@ Resources: Type: HttpApi Properties: ApiId: !Ref MyApi - + MyApi: Type: AWS::Serverless::HttpApi Properties: DisableExecuteApiEndpoint: true - StageName: Prod \ No newline at end of file + StageName: Prod diff --git a/tests/functional/commands/validate/lib/models/api_with_basic_custom_domain_intrinsics.yaml b/tests/functional/commands/validate/lib/models/api_with_basic_custom_domain_intrinsics.yaml index b1d6427544..90f466dccf 100644 --- a/tests/functional/commands/validate/lib/models/api_with_basic_custom_domain_intrinsics.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_basic_custom_domain_intrinsics.yaml @@ -1,14 +1,16 @@ +%YAML 1.1 +--- Conditions: C1: Fn::Equals: - - true - - true + - true + - true Parameters: - MyDomainCert: + MyDomainCert: Type: String Default: another-api-arn - EndpointConf: + EndpointConf: Type: String Default: REGIONAL @@ -58,9 +60,8 @@ Resources: DomainName: !Sub 'example-${AWS::Region}.com' CertificateArn: !Ref MyDomainCert EndpointConfiguration: !Ref EndpointConf - BasePath: [ "/get", "/fetch" ] + BasePath: [/get, /fetch] MutualTlsAuthentication: TruststoreUri: !Ref MyMTLSUri TruststoreVersion: !Ref MyMTLSVersion SecurityPolicy: TLS_1_2 - diff --git a/tests/functional/commands/validate/lib/models/api_with_basic_custom_domain_intrinsics_http.yaml b/tests/functional/commands/validate/lib/models/api_with_basic_custom_domain_intrinsics_http.yaml index b445a3bbbf..fce95a622b 100644 --- a/tests/functional/commands/validate/lib/models/api_with_basic_custom_domain_intrinsics_http.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_basic_custom_domain_intrinsics_http.yaml @@ -1,14 +1,16 @@ +%YAML 1.1 +--- Conditions: C1: Fn::Equals: - - true - - true + - true + - true Parameters: - MyDomainCert: + MyDomainCert: Type: String Default: another-api-arn - EndpointConf: + EndpointConf: Type: String Default: REGIONAL @@ -53,14 +55,13 @@ Resources: Type: AWS::Serverless::HttpApi Properties: StageName: Prod - DisableExecuteApiEndpoint: False + DisableExecuteApiEndpoint: false Domain: DomainName: !Sub 'example-${AWS::Region}.com' CertificateArn: !Ref MyDomainCert EndpointConfiguration: !Ref EndpointConf - BasePath: [ "/get", "/fetch" ] + BasePath: [/get, /fetch] MutualTlsAuthentication: TruststoreUri: !Ref MyMTLSUriHTTP TruststoreVersion: !Ref MyMTLSVersionHTTP SecurityPolicy: TLS_1_2 - diff --git a/tests/functional/commands/validate/lib/models/api_with_binary_media_types.yaml b/tests/functional/commands/validate/lib/models/api_with_binary_media_types.yaml index 2a10a2aa1d..90c6303210 100644 --- a/tests/functional/commands/validate/lib/models/api_with_binary_media_types.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_binary_media_types.yaml @@ -1,12 +1,14 @@ +%YAML 1.1 +--- Parameters: BMT: Type: String - Default: 'image~1jpg' + Default: image~1jpg Globals: Api: BinaryMediaTypes: - - image~1gif - - {"Fn::Join": ["~1", ["image", "png"]]} + - image~1gif + - {Fn::Join: [~1, [image, png]]} Resources: ImplicitApiFunction: @@ -28,5 +30,5 @@ Resources: StageName: Prod DefinitionUri: s3://sam-demo-bucket/webpage_swagger.json BinaryMediaTypes: - - application~1octet-stream - - !Ref BMT + - application~1octet-stream + - !Ref BMT diff --git a/tests/functional/commands/validate/lib/models/api_with_binary_media_types_definition_body.yaml b/tests/functional/commands/validate/lib/models/api_with_binary_media_types_definition_body.yaml index 6730419d4f..8351354ab2 100644 --- a/tests/functional/commands/validate/lib/models/api_with_binary_media_types_definition_body.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_binary_media_types_definition_body.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: BMT: Type: String @@ -5,9 +7,9 @@ Parameters: Globals: Api: BinaryMediaTypes: - - !Ref BMT - - image~1jpg - - {"Fn::Join": ["~1", ["image", "png"]]} + - !Ref BMT + - image~1jpg + - {Fn::Join: [~1, [image, png]]} Resources: ExplicitApiManagedSwagger: @@ -15,15 +17,12 @@ Resources: Properties: StageName: Prod BinaryMediaTypes: - - image~1gif + - image~1gif ExplicitApiDefinitionBody: Type: AWS::Serverless::Api Properties: StageName: Prod BinaryMediaTypes: - - application~1json - DefinitionBody: { - "paths": {}, - "swagger": "2.0", - } + - application~1json + DefinitionBody: {paths: {}, swagger: '2.0'} diff --git a/tests/functional/commands/validate/lib/models/api_with_canary_setting.yaml b/tests/functional/commands/validate/lib/models/api_with_canary_setting.yaml index 4503274c94..7185e42a8a 100644 --- a/tests/functional/commands/validate/lib/models/api_with_canary_setting.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_canary_setting.yaml @@ -1,10 +1,12 @@ +%YAML 1.1 +--- Globals: Api: CanarySetting: PercentTraffic: 100 StageVariablesOverrides: - sv1: "test" - sv2: "test2" + sv1: test + sv2: test2 UseStageCache: false Resources: diff --git a/tests/functional/commands/validate/lib/models/api_with_cors.yaml b/tests/functional/commands/validate/lib/models/api_with_cors.yaml index 56b1c0e804..99f76837b4 100644 --- a/tests/functional/commands/validate/lib/models/api_with_cors.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_cors.yaml @@ -1,8 +1,8 @@ +%YAML 1.1 +--- Globals: Api: - Cors: { - "Fn::Join": [",", ["www.amazon.com", "www.google.com"]] - } + Cors: {Fn::Join: [',', [www.amazon.com, www.google.com]]} Resources: ImplicitApiFunction: @@ -38,43 +38,14 @@ Resources: Type: AWS::Serverless::Api Properties: StageName: Prod - DefinitionBody: { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/add": { - "post": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${RestApiFunction.Arn}/invocations" - } - }, - "responses": {} - } - }, - "/{proxy+}": { - "x-amazon-apigateway-any-method": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetHtmlFunction.Arn}/invocations" - } - }, - "responses": {} - } - } - }, - "swagger": "2.0" - } + DefinitionBody: {info: {version: '1.0', title: {Ref: AWS::StackName}}, paths: { + /add: {post: {x-amazon-apigateway-integration: {httpMethod: POST, type: aws_proxy, + uri: {Fn::Sub: 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${RestApiFunction.Arn}/invocations'}}, + responses: {}}}, '/{proxy+}': {x-amazon-apigateway-any-method: {x-amazon-apigateway-integration: { + httpMethod: POST, type: aws_proxy, uri: {Fn::Sub: 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetHtmlFunction.Arn}/invocations'}}, + responses: {}}}}, swagger: '2.0'} Cors: - AllowMethods: "methods" - AllowHeaders: "headers" - AllowOrigin: "origins" + AllowMethods: methods + AllowHeaders: headers + AllowOrigin: origins AllowCredentials: true diff --git a/tests/functional/commands/validate/lib/models/api_with_cors_and_auth_no_preflight_auth.yaml b/tests/functional/commands/validate/lib/models/api_with_cors_and_auth_no_preflight_auth.yaml index e4e494082c..9039fc893e 100644 --- a/tests/functional/commands/validate/lib/models/api_with_cors_and_auth_no_preflight_auth.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_cors_and_auth_no_preflight_auth.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Globals: Api: - Cors: "origins" + Cors: origins Resources: ApiFunction: @@ -30,7 +32,7 @@ Resources: Properties: StageName: Prod Auth: - AddDefaultAuthorizerToCorsPreflight: False + AddDefaultAuthorizerToCorsPreflight: false DefaultAuthorizer: MyLambdaRequestAuth Authorizers: MyLambdaRequestAuth: @@ -38,11 +40,11 @@ Resources: FunctionArn: !GetAtt MyAuthFn.Arn Identity: Headers: - - Authorization1 + - Authorization1 MyAuthFn: Type: AWS::Serverless::Function Properties: CodeUri: s3://bucket/key Handler: index.handler - Runtime: nodejs12.x \ No newline at end of file + Runtime: nodejs12.x diff --git a/tests/functional/commands/validate/lib/models/api_with_cors_and_auth_preflight_auth.yaml b/tests/functional/commands/validate/lib/models/api_with_cors_and_auth_preflight_auth.yaml index 1fb222b890..449a52e13a 100644 --- a/tests/functional/commands/validate/lib/models/api_with_cors_and_auth_preflight_auth.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_cors_and_auth_preflight_auth.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Globals: Api: - Cors: "origins" + Cors: origins Resources: ApiFunction: @@ -44,11 +46,11 @@ Resources: FunctionArn: !GetAtt MyAuthFn.Arn Identity: Headers: - - Authorization1 + - Authorization1 MyAuthFn: Type: AWS::Serverless::Function Properties: CodeUri: s3://bucket/key Handler: index.handler - Runtime: nodejs12.x \ No newline at end of file + Runtime: nodejs12.x diff --git a/tests/functional/commands/validate/lib/models/api_with_cors_and_conditions_no_definitionbody.yaml b/tests/functional/commands/validate/lib/models/api_with_cors_and_conditions_no_definitionbody.yaml index 5075726ae7..ca9d804534 100644 --- a/tests/functional/commands/validate/lib/models/api_with_cors_and_conditions_no_definitionbody.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_cors_and_conditions_no_definitionbody.yaml @@ -1,10 +1,12 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Conditions: MyCondition: Fn::Equals: - - true - - true + - true + - true Globals: Api: # If we skip AllowMethods, then SAM will auto generate a list of methods scoped to each path @@ -59,4 +61,4 @@ Resources: ExplicitApi: Type: AWS::Serverless::Api Properties: - StageName: Prod \ No newline at end of file + StageName: Prod diff --git a/tests/functional/commands/validate/lib/models/api_with_cors_and_only_credentials_false.yaml b/tests/functional/commands/validate/lib/models/api_with_cors_and_only_credentials_false.yaml index f5fd65d0bb..0a29f7d156 100644 --- a/tests/functional/commands/validate/lib/models/api_with_cors_and_only_credentials_false.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_cors_and_only_credentials_false.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: Api: Cors: @@ -14,41 +16,9 @@ Resources: Type: AWS::Serverless::Api Properties: StageName: Prod - DefinitionBody: { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/add": { - "post": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations" - } - }, - "responses": {} - } - }, - "/{proxy+}": { - "x-amazon-apigateway-any-method": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations" - } - }, - "responses": {} - } - } - }, - "swagger": "2.0" - } - - - + DefinitionBody: {info: {version: '1.0', title: {Ref: AWS::StackName}}, paths: { + /add: {post: {x-amazon-apigateway-integration: {httpMethod: POST, type: aws_proxy, + uri: {Fn::Sub: 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations'}}, + responses: {}}}, '/{proxy+}': {x-amazon-apigateway-any-method: {x-amazon-apigateway-integration: { + httpMethod: POST, type: aws_proxy, uri: {Fn::Sub: 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations'}}, + responses: {}}}}, swagger: '2.0'} diff --git a/tests/functional/commands/validate/lib/models/api_with_cors_and_only_headers.yaml b/tests/functional/commands/validate/lib/models/api_with_cors_and_only_headers.yaml index 4619d39b93..768013cafa 100644 --- a/tests/functional/commands/validate/lib/models/api_with_cors_and_only_headers.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_cors_and_only_headers.yaml @@ -1,9 +1,11 @@ +%YAML 1.1 +--- Globals: Api: Cors: # If we skip AllowMethods, then SAM will auto generate a list of methods scoped to each path - AllowHeaders: "headers" + AllowHeaders: headers Resources: ImplicitApiFunction: @@ -30,41 +32,9 @@ Resources: Type: AWS::Serverless::Api Properties: StageName: Prod - DefinitionBody: { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/add": { - "post": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations" - } - }, - "responses": {} - } - }, - "/{proxy+}": { - "x-amazon-apigateway-any-method": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations" - } - }, - "responses": {} - } - } - }, - "swagger": "2.0" - } - - - + DefinitionBody: {info: {version: '1.0', title: {Ref: AWS::StackName}}, paths: { + /add: {post: {x-amazon-apigateway-integration: {httpMethod: POST, type: aws_proxy, + uri: {Fn::Sub: 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations'}}, + responses: {}}}, '/{proxy+}': {x-amazon-apigateway-any-method: {x-amazon-apigateway-integration: { + httpMethod: POST, type: aws_proxy, uri: {Fn::Sub: 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations'}}, + responses: {}}}}, swagger: '2.0'} diff --git a/tests/functional/commands/validate/lib/models/api_with_cors_and_only_maxage.yaml b/tests/functional/commands/validate/lib/models/api_with_cors_and_only_maxage.yaml index 2e1ed30a35..0cc4cc8470 100644 --- a/tests/functional/commands/validate/lib/models/api_with_cors_and_only_maxage.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_cors_and_only_maxage.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: Api: Cors: @@ -15,41 +17,9 @@ Resources: Type: AWS::Serverless::Api Properties: StageName: Prod - DefinitionBody: { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/add": { - "post": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations" - } - }, - "responses": {} - } - }, - "/{proxy+}": { - "x-amazon-apigateway-any-method": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations" - } - }, - "responses": {} - } - } - }, - "swagger": "2.0" - } - - - + DefinitionBody: {info: {version: '1.0', title: {Ref: AWS::StackName}}, paths: { + /add: {post: {x-amazon-apigateway-integration: {httpMethod: POST, type: aws_proxy, + uri: {Fn::Sub: 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations'}}, + responses: {}}}, '/{proxy+}': {x-amazon-apigateway-any-method: {x-amazon-apigateway-integration: { + httpMethod: POST, type: aws_proxy, uri: {Fn::Sub: 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations'}}, + responses: {}}}}, swagger: '2.0'} diff --git a/tests/functional/commands/validate/lib/models/api_with_cors_and_only_methods.yaml b/tests/functional/commands/validate/lib/models/api_with_cors_and_only_methods.yaml index 724de43017..83117a5b9e 100644 --- a/tests/functional/commands/validate/lib/models/api_with_cors_and_only_methods.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_cors_and_only_methods.yaml @@ -1,7 +1,9 @@ +%YAML 1.1 +--- Globals: Api: Cors: - AllowMethods: "methods" + AllowMethods: methods Resources: ImplicitApiFunction: @@ -21,4 +23,3 @@ Resources: Properties: Path: /any Method: any - diff --git a/tests/functional/commands/validate/lib/models/api_with_cors_and_only_origins.yaml b/tests/functional/commands/validate/lib/models/api_with_cors_and_only_origins.yaml index b8083247ec..fc6fd28886 100644 --- a/tests/functional/commands/validate/lib/models/api_with_cors_and_only_origins.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_cors_and_only_origins.yaml @@ -1,7 +1,9 @@ +%YAML 1.1 +--- Globals: Api: # If we skip AllowMethods, then SAM will auto generate a list of methods scoped to each path - Cors: "origins" + Cors: origins Resources: ImplicitApiFunction: @@ -28,41 +30,9 @@ Resources: Type: AWS::Serverless::Api Properties: StageName: Prod - DefinitionBody: { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/add": { - "post": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations" - } - }, - "responses": {} - } - }, - "/{proxy+}": { - "x-amazon-apigateway-any-method": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations" - } - }, - "responses": {} - } - } - }, - "swagger": "2.0" - } - - - + DefinitionBody: {info: {version: '1.0', title: {Ref: AWS::StackName}}, paths: { + /add: {post: {x-amazon-apigateway-integration: {httpMethod: POST, type: aws_proxy, + uri: {Fn::Sub: 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations'}}, + responses: {}}}, '/{proxy+}': {x-amazon-apigateway-any-method: {x-amazon-apigateway-integration: { + httpMethod: POST, type: aws_proxy, uri: {Fn::Sub: 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations'}}, + responses: {}}}}, swagger: '2.0'} diff --git a/tests/functional/commands/validate/lib/models/api_with_cors_no_definitionbody.yaml b/tests/functional/commands/validate/lib/models/api_with_cors_no_definitionbody.yaml index 7d496c2f9b..da4f2347ce 100644 --- a/tests/functional/commands/validate/lib/models/api_with_cors_no_definitionbody.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_cors_no_definitionbody.yaml @@ -1,9 +1,11 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Globals: Api: # If we skip AllowMethods, then SAM will auto generate a list of methods scoped to each path - Cors: "origins" + Cors: origins Resources: ImplicitApiFunction: @@ -38,4 +40,4 @@ Resources: ExplicitApi: Type: AWS::Serverless::Api Properties: - StageName: Prod \ No newline at end of file + StageName: Prod diff --git a/tests/functional/commands/validate/lib/models/api_with_cors_openapi_3.yaml b/tests/functional/commands/validate/lib/models/api_with_cors_openapi_3.yaml index 31ff41b122..389448525a 100644 --- a/tests/functional/commands/validate/lib/models/api_with_cors_openapi_3.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_cors_openapi_3.yaml @@ -1,8 +1,8 @@ +%YAML 1.1 +--- Globals: Api: - Cors: { - "Fn::Join": [",", ["www.amazon.com", "www.google.com"]] - } + Cors: {Fn::Join: [',', [www.amazon.com, www.google.com]]} OpenApiVersion: '3.0' @@ -40,43 +40,14 @@ Resources: Type: AWS::Serverless::Api Properties: StageName: Prod - DefinitionBody: { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/add": { - "post": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${RestApiFunction.Arn}/invocations" - } - }, - "responses": {} - } - }, - "/{proxy+}": { - "x-amazon-apigateway-any-method": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetHtmlFunction.Arn}/invocations" - } - }, - "responses": {} - } - } - }, - "swagger": "2.0" - } + DefinitionBody: {info: {version: '1.0', title: {Ref: AWS::StackName}}, paths: { + /add: {post: {x-amazon-apigateway-integration: {httpMethod: POST, type: aws_proxy, + uri: {Fn::Sub: 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${RestApiFunction.Arn}/invocations'}}, + responses: {}}}, '/{proxy+}': {x-amazon-apigateway-any-method: {x-amazon-apigateway-integration: { + httpMethod: POST, type: aws_proxy, uri: {Fn::Sub: 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetHtmlFunction.Arn}/invocations'}}, + responses: {}}}}, swagger: '2.0'} Cors: - AllowMethods: "methods" - AllowHeaders: "headers" - AllowOrigin: "origins" + AllowMethods: methods + AllowHeaders: headers + AllowOrigin: origins AllowCredentials: true diff --git a/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53.yaml b/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53.yaml index 1d61f37b1d..54312990c0 100644 --- a/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53.yaml @@ -1,10 +1,12 @@ +%YAML 1.1 +--- Parameters: DomainName: Type: String - Default: 'example.com' + Default: example.com ACMCertificateArn: Type: String - Default: 'cert-arn-in-us-east-1' + Default: cert-arn-in-us-east-1 Resources: MyFunction: Type: AWS::Serverless::Function @@ -37,7 +39,7 @@ Resources: CertificateArn: !Ref ACMCertificateArn EndpointConfiguration: EDGE BasePath: - - /one + - /one Route53: - HostedZoneId: ZQ1UAL4EFZVME - IpV6: true \ No newline at end of file + HostedZoneId: ZQ1UAL4EFZVME + IpV6: true diff --git a/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_hosted_zone_name.yaml b/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_hosted_zone_name.yaml index 36120739ba..20344d7830 100644 --- a/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_hosted_zone_name.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_hosted_zone_name.yaml @@ -1,10 +1,12 @@ +%YAML 1.1 +--- Parameters: DomainName: Type: String - Default: 'example.com' + Default: example.com ACMCertificateArn: Type: String - Default: 'cert-arn-in-us-east-1' + Default: cert-arn-in-us-east-1 Resources: MyFunction: Type: AWS::Serverless::Function @@ -37,7 +39,7 @@ Resources: CertificateArn: !Ref ACMCertificateArn EndpointConfiguration: EDGE BasePath: - - /one + - /one Route53: - HostedZoneName: www.my-domain.com. - IpV6: true \ No newline at end of file + HostedZoneName: www.my-domain.com. + IpV6: true diff --git a/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_hosted_zone_name_http.yaml b/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_hosted_zone_name_http.yaml index 9fbc632a89..d5c20d0b97 100644 --- a/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_hosted_zone_name_http.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_hosted_zone_name_http.yaml @@ -1,17 +1,19 @@ +%YAML 1.1 +--- Parameters: DomainName: Type: String - Default: 'example.com' + Default: example.com ACMCertificateArn: Type: String - Default: 'cert-arn-in-us-east-1' + Default: cert-arn-in-us-east-1 Globals: HttpApi: Domain: DomainName: !Ref DomainName CertificateArn: !Ref ACMCertificateArn BasePath: - - /one + - /one Route53: HostedZoneName: www.my-domain.com. IpV6: false diff --git a/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_http.yaml b/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_http.yaml index f3e91b05d2..8388309bd4 100644 --- a/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_http.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_http.yaml @@ -1,10 +1,12 @@ +%YAML 1.1 +--- Parameters: DomainName: Type: String - Default: 'example.com' + Default: example.com ACMCertificateArn: Type: String - Default: 'cert-arn-in-us-east-1' + Default: cert-arn-in-us-east-1 Resources: MyFunction: Type: AWS::Serverless::Function @@ -35,7 +37,7 @@ Resources: DomainName: !Ref DomainName CertificateArn: !Ref ACMCertificateArn BasePath: - - /one + - /one Route53: - HostedZoneId: ZQ1UAL4EFZVME - IpV6: true \ No newline at end of file + HostedZoneId: ZQ1UAL4EFZVME + IpV6: true diff --git a/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_multiple.yaml b/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_multiple.yaml index 6bfe59c91e..5d641bd51f 100644 --- a/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_multiple.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_multiple.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > @@ -6,7 +8,6 @@ Description: > Sample SAM Template for apigateway-2402 Resources: - ApiGatewayAdminOne: Type: AWS::Serverless::Api Properties: @@ -14,19 +15,19 @@ Resources: StageName: Prod TracingEnabled: true MethodSettings: - - LoggingLevel: Info - ResourcePath: '/*' - HttpMethod: '*' + - LoggingLevel: Info + ResourcePath: /* + HttpMethod: '*' Domain: DomainName: admin.one.amazon.com CertificateArn: arn::cert::abc EndpointConfiguration: REGIONAL Route53: - HostedZoneId: "abc123456" + HostedZoneId: abc123456 EndpointConfiguration: Type: REGIONAL - + ApiGatewayAdminTwo: Type: AWS::Serverless::Api Properties: @@ -34,19 +35,19 @@ Resources: StageName: Prod TracingEnabled: true MethodSettings: - - LoggingLevel: Info - ResourcePath: '/*' - HttpMethod: '*' + - LoggingLevel: Info + ResourcePath: /* + HttpMethod: '*' Domain: DomainName: admin.two.amazon.com CertificateArn: arn::cert::abc EndpointConfiguration: REGIONAL Route53: - HostedZoneId: "abc123456" + HostedZoneId: abc123456 EndpointConfiguration: Type: REGIONAL - - + + ApiGatewayAdminThree: Type: AWS::Serverless::Api Properties: @@ -54,14 +55,14 @@ Resources: StageName: Prod TracingEnabled: true MethodSettings: - - LoggingLevel: Info - ResourcePath: '/*' - HttpMethod: '*' + - LoggingLevel: Info + ResourcePath: /* + HttpMethod: '*' Domain: DomainName: admin.three.amazon.com CertificateArn: arn::cert::abc EndpointConfiguration: REGIONAL Route53: - HostedZoneId: "abc123456" + HostedZoneId: abc123456 EndpointConfiguration: Type: REGIONAL diff --git a/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_multiple_intrinsic_hostedzoneid.yaml b/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_multiple_intrinsic_hostedzoneid.yaml index bb0eaf6b27..0835d87b01 100644 --- a/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_multiple_intrinsic_hostedzoneid.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_custom_domain_route53_multiple_intrinsic_hostedzoneid.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > @@ -10,7 +12,6 @@ Parameters: Type: String Resources: - ApiGatewayAdminOne: Type: AWS::Serverless::Api Properties: @@ -18,9 +19,9 @@ Resources: StageName: Prod TracingEnabled: true MethodSettings: - - LoggingLevel: Info - ResourcePath: '/*' - HttpMethod: '*' + - LoggingLevel: Info + ResourcePath: /* + HttpMethod: '*' Domain: DomainName: admin.one.amazon.com CertificateArn: arn::cert::abc @@ -30,7 +31,7 @@ Resources: EndpointConfiguration: Type: REGIONAL - + ApiGatewayAdminTwo: Type: AWS::Serverless::Api Properties: @@ -38,9 +39,9 @@ Resources: StageName: Prod TracingEnabled: true MethodSettings: - - LoggingLevel: Info - ResourcePath: '/*' - HttpMethod: '*' + - LoggingLevel: Info + ResourcePath: /* + HttpMethod: '*' Domain: DomainName: admin.two.amazon.com CertificateArn: arn::cert::abc @@ -49,8 +50,8 @@ Resources: HostedZoneId: !Sub "{{MyHostedZoneId}}" EndpointConfiguration: Type: REGIONAL - - + + ApiGatewayAdminThree: Type: AWS::Serverless::Api Properties: @@ -58,9 +59,9 @@ Resources: StageName: Prod TracingEnabled: true MethodSettings: - - LoggingLevel: Info - ResourcePath: '/*' - HttpMethod: '*' + - LoggingLevel: Info + ResourcePath: /* + HttpMethod: '*' Domain: DomainName: admin.three.amazon.com CertificateArn: arn::cert::abc diff --git a/tests/functional/commands/validate/lib/models/api_with_default_aws_iam_auth.yaml b/tests/functional/commands/validate/lib/models/api_with_default_aws_iam_auth.yaml index 2c32c89fdd..d13ddc52e6 100644 --- a/tests/functional/commands/validate/lib/models/api_with_default_aws_iam_auth.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_default_aws_iam_auth.yaml @@ -1,20 +1,22 @@ +%YAML 1.1 +--- Resources: MyApiWithAwsIamAuthAndDefaultInvokeRole: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: DefaultAuthorizer: AWS_IAM InvokeRole: CALLER_CREDENTIALS MyApiWithAwsIamAuthAndCustomInvokeRole: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: DefaultAuthorizer: AWS_IAM InvokeRole: rn:aws:iam::123:role/AUTH_AWS_IAM MyApiWithAwsIamAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: diff --git a/tests/functional/commands/validate/lib/models/api_with_default_aws_iam_auth_and_no_auth_route.yaml b/tests/functional/commands/validate/lib/models/api_with_default_aws_iam_auth_and_no_auth_route.yaml index d3d69d577c..663dddaf96 100644 --- a/tests/functional/commands/validate/lib/models/api_with_default_aws_iam_auth_and_no_auth_route.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_default_aws_iam_auth_and_no_auth_route.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyApiWithAwsIamAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -32,7 +34,7 @@ Resources: Path: / Method: get Auth: - Authorizer: 'NONE' + Authorizer: NONE MyApiWithNoAuthAnyMethod: Type: Api Properties: @@ -40,4 +42,4 @@ Resources: Path: /any/none Method: any Auth: - Authorizer: 'NONE' + Authorizer: NONE diff --git a/tests/functional/commands/validate/lib/models/api_with_disable_api_execute_endpoint.yaml b/tests/functional/commands/validate/lib/models/api_with_disable_api_execute_endpoint.yaml index 7be8dc3e51..dedcbd6760 100644 --- a/tests/functional/commands/validate/lib/models/api_with_disable_api_execute_endpoint.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_disable_api_execute_endpoint.yaml @@ -1,9 +1,11 @@ +%YAML 1.1 +--- Resources: ApiGatewayApi: Type: AWS::Serverless::Api Properties: StageName: prod - DisableExecuteApiEndpoint: True + DisableExecuteApiEndpoint: true ApiFunction: # Adds a GET api endpoint at "/" to the ApiGatewayApi via an Api event Type: AWS::Serverless::Function Properties: @@ -17,6 +19,6 @@ Resources: Ref: ApiGatewayApi Runtime: python3.7 Handler: index.handler - InlineCode: | + InlineCode: |- def handler(event, context): - return {'body': 'Hello World!', 'statusCode': 200} \ No newline at end of file + return {'body': 'Hello World!', 'statusCode': 200} diff --git a/tests/functional/commands/validate/lib/models/api_with_disable_api_execute_endpoint_openapi_3.yaml b/tests/functional/commands/validate/lib/models/api_with_disable_api_execute_endpoint_openapi_3.yaml new file mode 100644 index 0000000000..bd9867b9a3 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/api_with_disable_api_execute_endpoint_openapi_3.yaml @@ -0,0 +1,25 @@ +%YAML 1.1 +--- +Resources: + ApiGatewayApi: + Type: AWS::Serverless::Api + Properties: + StageName: prod + OpenApiVersion: 3.0 + DisableExecuteApiEndpoint: true + ApiFunction: + Type: AWS::Serverless::Function + Properties: + Events: + ApiEvent: + Type: Api + Properties: + Path: / + Method: get + RestApiId: + Ref: ApiGatewayApi + Runtime: python3.7 + Handler: index.handler + InlineCode: |- + def handler(event, context): + return {'body': 'Hello World!', 'statusCode': 200} diff --git a/tests/functional/commands/validate/lib/models/api_with_fail_on_warnings.yaml b/tests/functional/commands/validate/lib/models/api_with_fail_on_warnings.yaml index 354eeaf761..99f6b7ca40 100644 --- a/tests/functional/commands/validate/lib/models/api_with_fail_on_warnings.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_fail_on_warnings.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: ApiGatewayApi: Type: AWS::Serverless::Api diff --git a/tests/functional/commands/validate/lib/models/api_with_gateway_responses.yaml b/tests/functional/commands/validate/lib/models/api_with_gateway_responses.yaml index fe90cfaa34..7213c7a3c2 100644 --- a/tests/functional/commands/validate/lib/models/api_with_gateway_responses.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_gateway_responses.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: Function: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/api_with_gateway_responses_all.yaml b/tests/functional/commands/validate/lib/models/api_with_gateway_responses_all.yaml index 1ae216968d..cd3b7781c3 100644 --- a/tests/functional/commands/validate/lib/models/api_with_gateway_responses_all.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_gateway_responses_all.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: Function: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/api_with_gateway_responses_all_openapi_3.yaml b/tests/functional/commands/validate/lib/models/api_with_gateway_responses_all_openapi_3.yaml index 9b32bf2d94..6d71de6bff 100644 --- a/tests/functional/commands/validate/lib/models/api_with_gateway_responses_all_openapi_3.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_gateway_responses_all_openapi_3.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: Function: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/api_with_gateway_responses_implicit.yaml b/tests/functional/commands/validate/lib/models/api_with_gateway_responses_implicit.yaml index 4c6cdfd242..b65976ae9d 100644 --- a/tests/functional/commands/validate/lib/models/api_with_gateway_responses_implicit.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_gateway_responses_implicit.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Globals: Api: - Name: "some api" + Name: some api GatewayResponses: UNAUTHORIZED: StatusCode: 401 @@ -24,4 +26,4 @@ Resources: Type: Api Properties: Path: / - Method: get \ No newline at end of file + Method: get diff --git a/tests/functional/commands/validate/lib/models/api_with_gateway_responses_minimal.yaml b/tests/functional/commands/validate/lib/models/api_with_gateway_responses_minimal.yaml index 77879bf424..8cafe732fa 100644 --- a/tests/functional/commands/validate/lib/models/api_with_gateway_responses_minimal.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_gateway_responses_minimal.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: Function: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/api_with_gateway_responses_string_status_code.yaml b/tests/functional/commands/validate/lib/models/api_with_gateway_responses_string_status_code.yaml index b37f6d446c..95b0f0d278 100644 --- a/tests/functional/commands/validate/lib/models/api_with_gateway_responses_string_status_code.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_gateway_responses_string_status_code.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: Function: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/api_with_identity_intrinsic.yaml b/tests/functional/commands/validate/lib/models/api_with_identity_intrinsic.yaml index 2afc3d679a..62d4611c6e 100644 --- a/tests/functional/commands/validate/lib/models/api_with_identity_intrinsic.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_identity_intrinsic.yaml @@ -1,4 +1,6 @@ -AWSTemplateFormatVersion: "2010-09-09" +%YAML 1.1 +--- +AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Conditions: @@ -7,7 +9,7 @@ Conditions: Resources: APIGateway: - Type: 'AWS::Serverless::Api' + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -18,5 +20,5 @@ Resources: FunctionArn: SomeArn Identity: Headers: - - Accept - ReauthorizeEvery: !If [isProd, 3600, 0] \ No newline at end of file + - Accept + ReauthorizeEvery: !If [isProd, 3600, 0] diff --git a/tests/functional/commands/validate/lib/models/api_with_if_conditional_with_resource_policy.yaml b/tests/functional/commands/validate/lib/models/api_with_if_conditional_with_resource_policy.yaml index cfbc74ec1e..be46c3ab13 100644 --- a/tests/functional/commands/validate/lib/models/api_with_if_conditional_with_resource_policy.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_if_conditional_with_resource_policy.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- Conditions: C1: Fn::Equals: - - true - - true + - true + - true Resources: ExplicitApi: Type: AWS::Serverless::Api @@ -10,17 +12,9 @@ Resources: StageName: Prod Auth: ResourcePolicy: - CustomStatements: - Fn::If: [ - C1, - { - Action: 'execute-api:Invoke', - Resource: ['execute-api:/*/*/*'] - }, - { - Ref: 'AWS::NoValue' - }, - ] + CustomStatements: + Fn::If: [C1, {Action: execute-api:Invoke, Resource: [execute-api:/*/*/*]}, + Ref: AWS::NoValue] ExplicitApiFunction: Type: AWS::Serverless::Function @@ -57,5 +51,3 @@ Resources: Ref: ExplicitApi Path: /any Method: any - - \ No newline at end of file diff --git a/tests/functional/commands/validate/lib/models/api_with_incompatible_stage_name.yaml b/tests/functional/commands/validate/lib/models/api_with_incompatible_stage_name.yaml index d9bb9032f6..a8ad428490 100644 --- a/tests/functional/commands/validate/lib/models/api_with_incompatible_stage_name.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_incompatible_stage_name.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HyphenFunction: Type: AWS::Serverless::Function @@ -26,7 +28,7 @@ Resources: properties: username: type: string - + UnderscoreFunction: Type: AWS::Serverless::Function Properties: @@ -53,4 +55,4 @@ Resources: type: object properties: username: - type: string \ No newline at end of file + type: string diff --git a/tests/functional/commands/validate/lib/models/api_with_ip_range_blacklist.yaml b/tests/functional/commands/validate/lib/models/api_with_ip_range_blacklist.yaml index cc8650fc5b..35142f565f 100644 --- a/tests/functional/commands/validate/lib/models/api_with_ip_range_blacklist.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_ip_range_blacklist.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- Globals: Api: Auth: ResourcePolicy: - IpRangeBlacklist: ['1.2.3.4'] + IpRangeBlacklist: [1.2.3.4] AwsAccountWhitelist: ['12345'] Resources: MyFunction: diff --git a/tests/functional/commands/validate/lib/models/api_with_ip_range_whitelist.yaml b/tests/functional/commands/validate/lib/models/api_with_ip_range_whitelist.yaml index a33b0b982c..a2451dd1f3 100644 --- a/tests/functional/commands/validate/lib/models/api_with_ip_range_whitelist.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_ip_range_whitelist.yaml @@ -1,9 +1,11 @@ +%YAML 1.1 +--- Globals: Api: Auth: ResourcePolicy: - IpRangeWhitelist: ['1.2.3.4'] - IpRangeBlacklist: ['1.2.3.4'] + IpRangeWhitelist: [1.2.3.4] + IpRangeBlacklist: [1.2.3.4] Resources: MyFunction: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/api_with_method_aws_iam_auth.yaml b/tests/functional/commands/validate/lib/models/api_with_method_aws_iam_auth.yaml index 16c06dc43e..0c6e30aae0 100644 --- a/tests/functional/commands/validate/lib/models/api_with_method_aws_iam_auth.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_method_aws_iam_auth.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyApiWithoutAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod diff --git a/tests/functional/commands/validate/lib/models/api_with_method_settings.yaml b/tests/functional/commands/validate/lib/models/api_with_method_settings.yaml index 251b70c839..f139fc0c8c 100644 --- a/tests/functional/commands/validate/lib/models/api_with_method_settings.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_method_settings.yaml @@ -1,19 +1,9 @@ +%YAML 1.1 +--- Globals: Api: - MethodSettings: [{ - # LOGGING!! - "LoggingLevel": "INFO", - - # METRICS!! - "MetricsEnabled": True, - - # Trace-level Logging - "DataTraceEnabled": True, - - # On all Paths & methods - "ResourcePath": "/*", - "HttpMethod": "*", - }] + MethodSettings: [{LoggingLevel: INFO, MetricsEnabled: true, DataTraceEnabled: true, + ResourcePath: /*, HttpMethod: '*'}] Resources: ImplicitApiFunction: diff --git a/tests/functional/commands/validate/lib/models/api_with_minimum_compression_size.yaml b/tests/functional/commands/validate/lib/models/api_with_minimum_compression_size.yaml index cb2ea975c5..1ff6e0951f 100644 --- a/tests/functional/commands/validate/lib/models/api_with_minimum_compression_size.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_minimum_compression_size.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: Api: MinimumCompressionSize: 1024 diff --git a/tests/functional/commands/validate/lib/models/api_with_mode.yaml b/tests/functional/commands/validate/lib/models/api_with_mode.yaml index 8df0693af4..ea8b8feaa4 100644 --- a/tests/functional/commands/validate/lib/models/api_with_mode.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_mode.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: Function: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/api_with_no_properties.yaml b/tests/functional/commands/validate/lib/models/api_with_no_properties.yaml index 5a963a3e9f..38f2b2c855 100644 --- a/tests/functional/commands/validate/lib/models/api_with_no_properties.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_no_properties.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HtmlFunction: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/api_with_open_api_version.yaml b/tests/functional/commands/validate/lib/models/api_with_open_api_version.yaml index 7efa33f629..73e88f0590 100644 --- a/tests/functional/commands/validate/lib/models/api_with_open_api_version.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_open_api_version.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: Api: OpenApiVersion: 3.0.1 diff --git a/tests/functional/commands/validate/lib/models/api_with_open_api_version_2.yaml b/tests/functional/commands/validate/lib/models/api_with_open_api_version_2.yaml index 52e6530326..3efe1c162f 100644 --- a/tests/functional/commands/validate/lib/models/api_with_open_api_version_2.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_open_api_version_2.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: Api: OpenApiVersion: '2.0' diff --git a/tests/functional/commands/validate/lib/models/api_with_openapi_definition_body_no_flag.yaml b/tests/functional/commands/validate/lib/models/api_with_openapi_definition_body_no_flag.yaml index d8ee227be0..235983eb14 100644 --- a/tests/functional/commands/validate/lib/models/api_with_openapi_definition_body_no_flag.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_openapi_definition_body_no_flag.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- Globals: Api: - Name: "some api" - CacheClusterEnabled: True - CacheClusterSize: "1.6" + Name: some api + CacheClusterEnabled: true + CacheClusterSize: '1.6' Auth: DefaultAuthorizer: MyCognitoAuth Authorizers: @@ -35,7 +37,7 @@ Resources: version: '1.0' title: !Ref AWS::StackName paths: - "/": + /: get: x-amazon-apigateway-integration: httpMethod: POST @@ -51,8 +53,8 @@ Resources: PasswordPolicy: MinimumLength: 8 UsernameAttributes: - - email + - email Schema: - - AttributeDataType: String - Name: email - Required: false \ No newline at end of file + - AttributeDataType: String + Name: email + Required: false diff --git a/tests/functional/commands/validate/lib/models/api_with_path_parameters.yaml b/tests/functional/commands/validate/lib/models/api_with_path_parameters.yaml index e1799d3e70..09d4085c85 100644 --- a/tests/functional/commands/validate/lib/models/api_with_path_parameters.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_path_parameters.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HtmlFunction: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/api_with_resource_policy.yaml b/tests/functional/commands/validate/lib/models/api_with_resource_policy.yaml index 2c34783842..55d2b2952c 100644 --- a/tests/functional/commands/validate/lib/models/api_with_resource_policy.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_resource_policy.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: ExplicitApi: Type: AWS::Serverless::Api @@ -5,10 +7,7 @@ Resources: StageName: Prod Auth: ResourcePolicy: - CustomStatements: { - Action: 'execute-api:Invoke', - Resource: ['execute-api:/*/*/*'] - } + CustomStatements: {Action: execute-api:Invoke, Resource: [execute-api:/*/*/*]} ExplicitApiFunction: Type: AWS::Serverless::Function Properties: @@ -44,5 +43,3 @@ Resources: Ref: ExplicitApi Path: /any Method: any - - \ No newline at end of file diff --git a/tests/functional/commands/validate/lib/models/api_with_resource_policy_global.yaml b/tests/functional/commands/validate/lib/models/api_with_resource_policy_global.yaml index 3bb00a4ef1..7f0ba75b32 100644 --- a/tests/functional/commands/validate/lib/models/api_with_resource_policy_global.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_resource_policy_global.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: StageName: Type: String @@ -5,21 +7,21 @@ Parameters: Conditions: C1: Fn::Equals: - - true - - true + - true + - true Globals: Api: Auth: ResourcePolicy: - CustomStatements: - Fn::If: - - C1 - - Action: execute-api:Invoke - Resource: - - execute-api:/*/*/* - - Action: execute-api:Blah - Resource: - - execute-api:/*/*/* + CustomStatements: + Fn::If: + - C1 + - Action: execute-api:Invoke + Resource: + - execute-api:/*/*/* + - Action: execute-api:Blah + Resource: + - execute-api:/*/*/* Resources: ExplicitApiFunction: Type: AWS::Serverless::Function @@ -46,7 +48,7 @@ Resources: version: '1.0' title: !Ref AWS::StackName paths: - "/": + /: get: x-amazon-apigateway-integration: httpMethod: POST @@ -56,22 +58,22 @@ Resources: x-amazon-apigateway-policy: Version: '2012-10-17' Statement: - Action: 'sts:AssumeRole' + Action: sts:AssumeRole Effect: Allow - Principal: - Service: 'lambda.amazonaws.com' + Principal: + Service: lambda.amazonaws.com AnotherApi: Type: AWS::Serverless::Api Properties: StageName: !Ref StageName Auth: ResourcePolicy: - CustomStatements: + CustomStatements: Fn::If: - - C1 - - Action: execute-api:Invoke - Resource: - - execute-api:/*/*/* - - Action: execute-api:Another - Resource: - - execute-api:/*/*/* + - C1 + - Action: execute-api:Invoke + Resource: + - execute-api:/*/*/* + - Action: execute-api:Another + Resource: + - execute-api:/*/*/* diff --git a/tests/functional/commands/validate/lib/models/api_with_resource_policy_global_implicit.yaml b/tests/functional/commands/validate/lib/models/api_with_resource_policy_global_implicit.yaml index 613f67dc10..ccf383f284 100644 --- a/tests/functional/commands/validate/lib/models/api_with_resource_policy_global_implicit.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_resource_policy_global_implicit.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -13,14 +15,8 @@ Resources: Method: post Auth: ResourcePolicy: - CustomStatements: [{ - Action: 'execute-api:Invoke', - Resource: ['execute-api:/*/*/*'] - }, - { - Action: 'execute-api:blah', - Resource: ['execute-api:/*/*/*'] - }] + CustomStatements: [{Action: execute-api:Invoke, Resource: [execute-api:/*/*/*]}, + {Action: execute-api:blah, Resource: [execute-api:/*/*/*]}] AddItemAnyMethod: Type: Api Properties: @@ -28,11 +24,5 @@ Resources: Method: any Auth: ResourcePolicy: - CustomStatements: [{ - Action: 'execute-api:Invoke', - Resource: ['execute-api:/*/*/*'] - }, - { - Action: 'execute-api:blah', - Resource: ['execute-api:/*/*/*'] - }] + CustomStatements: [{Action: execute-api:Invoke, Resource: [execute-api:/*/*/*]}, + {Action: execute-api:blah, Resource: [execute-api:/*/*/*]}] diff --git a/tests/functional/commands/validate/lib/models/api_with_resource_refs.yaml b/tests/functional/commands/validate/lib/models/api_with_resource_refs.yaml index e84845cbba..f8e40923fd 100644 --- a/tests/functional/commands/validate/lib/models/api_with_resource_refs.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_resource_refs.yaml @@ -1,16 +1,18 @@ +%YAML 1.1 +--- # Test if resource references work for both Explicit API & Implicit API resources Resources: MyApi: - Type: 'AWS::Serverless::Api' + Type: AWS::Serverless::Api Properties: StageName: foo DefinitionBody: - "this": "is" - "a": "swagger" + this: is + a: swagger MyFunction: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -36,4 +38,3 @@ Outputs: Value: !Ref MyApi.Deployment ExplicitApiStage: Value: !Ref MyApi.Stage - diff --git a/tests/functional/commands/validate/lib/models/api_with_security_definition_and_components.yaml b/tests/functional/commands/validate/lib/models/api_with_security_definition_and_components.yaml index 143b2bf0cd..6dc937ff48 100644 --- a/tests/functional/commands/validate/lib/models/api_with_security_definition_and_components.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_security_definition_and_components.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: GetHtmlFunction: Type: AWS::Serverless::Function @@ -16,23 +18,24 @@ Resources: Ref: AWS::StackName securityDefinitions: # 1 Add security definition CognitoAuthorizer: - type: "apiKey" - name: "Authorization" - in: "header" - x-amazon-apigateway-authtype: "cognito_user_pools" + type: apiKey + name: Authorization + in: header + x-amazon-apigateway-authtype: cognito_user_pools x-amazon-apigateway-authorizer: providerARNs: - - # userPool ARN - type: "cognito_user_pools" + - + # userPool ARN + type: cognito_user_pools paths: - "/{proxy+}": + /{proxy+}: x-amazon-apigateway-any-method: x-amazon-apigateway-integration: httpMethod: POST type: aws_proxy uri: Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetHtmlFunction.Arn}/invocations - responses: { } + responses: {} components: schemas: Error: @@ -40,4 +43,4 @@ Resources: properties: message: type: string - openapi: '3.0.0' + openapi: 3.0.0 diff --git a/tests/functional/commands/validate/lib/models/api_with_security_definition_and_no_components.yaml b/tests/functional/commands/validate/lib/models/api_with_security_definition_and_no_components.yaml index 4f39206148..c9506c7fe4 100644 --- a/tests/functional/commands/validate/lib/models/api_with_security_definition_and_no_components.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_security_definition_and_no_components.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: GetHtmlFunction: Type: AWS::Serverless::Function @@ -16,21 +18,22 @@ Resources: Ref: AWS::StackName securityDefinitions: # 1 Add security definition CognitoAuthorizer: - type: "apiKey" - name: "Authorization" - in: "header" - x-amazon-apigateway-authtype: "cognito_user_pools" + type: apiKey + name: Authorization + in: header + x-amazon-apigateway-authtype: cognito_user_pools x-amazon-apigateway-authorizer: providerARNs: - - # userPool ARN - type: "cognito_user_pools" + - + # userPool ARN + type: cognito_user_pools paths: - "/{proxy+}": + /{proxy+}: x-amazon-apigateway-any-method: x-amazon-apigateway-integration: httpMethod: POST type: aws_proxy uri: Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetHtmlFunction.Arn}/invocations - responses: { } - openapi: '3.0.0' + responses: {} + openapi: 3.0.0 diff --git a/tests/functional/commands/validate/lib/models/api_with_security_definition_and_none_components.yaml b/tests/functional/commands/validate/lib/models/api_with_security_definition_and_none_components.yaml index 7cad904f7a..5afcd76881 100644 --- a/tests/functional/commands/validate/lib/models/api_with_security_definition_and_none_components.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_security_definition_and_none_components.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: GetHtmlFunction: Type: AWS::Serverless::Function @@ -16,22 +18,23 @@ Resources: Ref: AWS::StackName securityDefinitions: # 1 Add security definition CognitoAuthorizer: - type: "apiKey" - name: "Authorization" - in: "header" - x-amazon-apigateway-authtype: "cognito_user_pools" + type: apiKey + name: Authorization + in: header + x-amazon-apigateway-authtype: cognito_user_pools x-amazon-apigateway-authorizer: providerARNs: - - # userPool ARN - type: "cognito_user_pools" + - + # userPool ARN + type: cognito_user_pools paths: - "/{proxy+}": + /{proxy+}: x-amazon-apigateway-any-method: x-amazon-apigateway-integration: httpMethod: POST type: aws_proxy uri: Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetHtmlFunction.Arn}/invocations - responses: { } + responses: {} components: - openapi: '3.0.0' + openapi: 3.0.0 diff --git a/tests/functional/commands/validate/lib/models/api_with_source_vpc_blacklist.yaml b/tests/functional/commands/validate/lib/models/api_with_source_vpc_blacklist.yaml index 6315a79314..f8989d927d 100644 --- a/tests/functional/commands/validate/lib/models/api_with_source_vpc_blacklist.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_source_vpc_blacklist.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- Globals: Api: Auth: ResourcePolicy: - SourceVpcBlacklist: ['vpce-3456'] + SourceVpcBlacklist: [vpce-3456] Resources: MyFunction: Type: AWS::Serverless::Function @@ -28,4 +30,3 @@ Resources: Properties: Method: any Path: /any/get - diff --git a/tests/functional/commands/validate/lib/models/api_with_source_vpc_whitelist.yaml b/tests/functional/commands/validate/lib/models/api_with_source_vpc_whitelist.yaml index f67ea34d8a..7a95209e98 100644 --- a/tests/functional/commands/validate/lib/models/api_with_source_vpc_whitelist.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_source_vpc_whitelist.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: Vpc1: Type: String @@ -7,9 +9,9 @@ Globals: Api: Auth: ResourcePolicy: - SourceVpcWhitelist: - - !Ref Vpc1 - - vpc-5678 + SourceVpcWhitelist: + - !Ref Vpc1 + - vpc-5678 Resources: MyFunction: @@ -51,4 +53,3 @@ Resources: Type: AWS::Serverless::Api Properties: StageName: Prod - diff --git a/tests/functional/commands/validate/lib/models/api_with_stage_tags.yaml b/tests/functional/commands/validate/lib/models/api_with_stage_tags.yaml index 83473e1163..2a7f447a86 100644 --- a/tests/functional/commands/validate/lib/models/api_with_stage_tags.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_stage_tags.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: TagValueParam: Type: String @@ -5,12 +7,12 @@ Parameters: Resources: MyApiWithStageTags: - Type: "AWS::Serverless::Api" - Properties: - StageName: Prod - Tags: - TagKey1: TagValue1 - TagKey2: "" - TagKey3: - Ref: TagValueParam - TagKey4: "123" + Type: AWS::Serverless::Api + Properties: + StageName: Prod + Tags: + TagKey1: TagValue1 + TagKey2: '' + TagKey3: + Ref: TagValueParam + TagKey4: '123' diff --git a/tests/functional/commands/validate/lib/models/api_with_swagger_and_openapi_with_auth.yaml b/tests/functional/commands/validate/lib/models/api_with_swagger_and_openapi_with_auth.yaml index 1b796e449b..75fa753e3e 100644 --- a/tests/functional/commands/validate/lib/models/api_with_swagger_and_openapi_with_auth.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_swagger_and_openapi_with_auth.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- Globals: Api: - Name: "some api" - CacheClusterEnabled: True - CacheClusterSize: "1.6" + Name: some api + CacheClusterEnabled: true + CacheClusterSize: '1.6' Auth: DefaultAuthorizer: MyCognitoAuth Authorizers: @@ -41,7 +43,7 @@ Resources: version: '1.0' title: !Ref AWS::StackName paths: - "/": + /: get: x-amazon-apigateway-integration: httpMethod: POST @@ -57,8 +59,8 @@ Resources: PasswordPolicy: MinimumLength: 8 UsernameAttributes: - - email + - email Schema: - - AttributeDataType: String - Name: email - Required: false \ No newline at end of file + - AttributeDataType: String + Name: email + Required: false diff --git a/tests/functional/commands/validate/lib/models/api_with_swagger_authorizer_none.yaml b/tests/functional/commands/validate/lib/models/api_with_swagger_authorizer_none.yaml index 98173772ec..e06f4e46ca 100644 --- a/tests/functional/commands/validate/lib/models/api_with_swagger_authorizer_none.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_swagger_authorizer_none.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyApiWithCognitoAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -10,7 +12,7 @@ Resources: DefaultAuthorizer: MyCognitoAuth MyApiWithLambdaTokenAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -20,7 +22,7 @@ Resources: DefaultAuthorizer: MyLambdaTokenAuth MyApiWithLambdaRequestAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod DefinitionBody: @@ -29,9 +31,9 @@ Resources: version: '1.0' title: !Ref AWS::StackName schemes: - - https + - https paths: - "/lambda-request": + /lambda-request: get: x-amazon-apigateway-integration: httpMethod: POST @@ -46,20 +48,20 @@ Resources: FunctionArn: !GetAtt MyAuthFn.Arn Identity: Headers: - - Authorization1 + - Authorization1 DefaultAuthorizer: MyLambdaRequestAuth MyAuthFn: Type: AWS::Serverless::Function Properties: InlineCode: | - exports.handler = async (event) => { - return { - statusCode: 200, - body: JSON.stringify(event), - headers: {} - } - } + exports.handler = async (event) => { + return { + statusCode: 200, + body: JSON.stringify(event), + headers: {} + } + } Handler: index.handler Runtime: nodejs8.10 @@ -67,13 +69,13 @@ Resources: Type: AWS::Serverless::Function Properties: InlineCode: | - exports.handler = async (event) => { - return { - statusCode: 200, - body: JSON.stringify(event), - headers: {} - } - } + exports.handler = async (event) => { + return { + statusCode: 200, + body: JSON.stringify(event), + headers: {} + } + } Handler: index.handler Runtime: nodejs8.10 Events: @@ -83,7 +85,7 @@ Resources: RestApiId: !Ref MyApiWithCognitoAuth Method: get Auth: - Authorizer: NONE + Authorizer: NONE Path: /cognito CognitoAnyMethod: Type: Api @@ -99,7 +101,7 @@ Resources: RestApiId: !Ref MyApiWithLambdaTokenAuth Method: get Auth: - Authorizer: NONE + Authorizer: NONE Path: /lambda-token LambdaTokenAnyMethod: Type: Api @@ -134,8 +136,8 @@ Resources: PasswordPolicy: MinimumLength: 8 UsernameAttributes: - - email + - email Schema: - - AttributeDataType: String - Name: email - Required: false \ No newline at end of file + - AttributeDataType: String + Name: email + Required: false diff --git a/tests/functional/commands/validate/lib/models/api_with_usageplans.yaml b/tests/functional/commands/validate/lib/models/api_with_usageplans.yaml index 41b08e493d..6d53943475 100644 --- a/tests/functional/commands/validate/lib/models/api_with_usageplans.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_usageplans.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: Api: Auth: @@ -6,142 +8,139 @@ Globals: CreateUsagePlan: SHARED Resources: - MyApiOne: - Type: AWS::Serverless::Api - Properties: - StageName: Prod - Auth: - UsagePlan: + MyApiOne: + Type: AWS::Serverless::Api + Properties: + StageName: Prod + Auth: + UsagePlan: CreateUsagePlan: NONE - MyApiTwo: - Type: AWS::Serverless::Api - Properties: - StageName: Prod - Auth: - UsagePlan: - CreateUsagePlan: PER_API - UsagePlanName: SomeRandomName - Description: "Description for usage plan" - Throttle: - BurstLimit: 1000 - RateLimit: 1000 - Tags: - - Key: key1 - Value: value1 - - Key: key2 - Value: value2 - Quota: - Limit: 10 - Offset: 10 - Period: MONTH + MyApiTwo: + Type: AWS::Serverless::Api + Properties: + StageName: Prod + Auth: + UsagePlan: + CreateUsagePlan: PER_API + UsagePlanName: SomeRandomName + Description: Description for usage plan + Throttle: + BurstLimit: 1000 + RateLimit: 1000 + Tags: + - Key: key1 + Value: value1 + - Key: key2 + Value: value2 + Quota: + Limit: 10 + Offset: 10 + Period: MONTH - MyApiThree: - Type: AWS::Serverless::Api - Properties: - StageName: Prod + MyApiThree: + Type: AWS::Serverless::Api + Properties: + StageName: Prod - MyFunctionOne: - Type: AWS::Serverless::Function - Properties: - Handler: index.handler - Runtime: nodejs12.x - InlineCode: | - exports.handler = async (event) => { - return { - statusCode: 200, - body: JSON.stringify(event), - headers: {} - } - } - Events: - ApiKey: - Type: Api - Properties: - RestApiId: - Ref: MyApiOne - Method: get - Path: /path/one - ApiKeyAnyMethod: - Type: Api - Properties: - RestApiId: - Ref: MyApiOne - Method: any - Path: /any/path/one + MyFunctionOne: + Type: AWS::Serverless::Function + Properties: + Handler: index.handler + Runtime: nodejs12.x + InlineCode: | + exports.handler = async (event) => { + return { + statusCode: 200, + body: JSON.stringify(event), + headers: {} + } + } + Events: + ApiKey: + Type: Api + Properties: + RestApiId: + Ref: MyApiOne + Method: get + Path: /path/one + ApiKeyAnyMethod: + Type: Api + Properties: + RestApiId: + Ref: MyApiOne + Method: any + Path: /any/path/one - MyFunctionTwo: - Type: AWS::Serverless::Function - Properties: - Handler: index.handler - Runtime: nodejs12.x - InlineCode: | - exports.handler = async (event) => { - return { - statusCode: 200, - body: JSON.stringify(event), - headers: {} - } - } - Events: - ApiKey: - Type: Api - Properties: - RestApiId: - Ref: MyApiTwo - Method: get - Path: /path/two - ImplicitApiEvent: - Type: Api - Properties: - Method: get - Path: /path/event + MyFunctionTwo: + Type: AWS::Serverless::Function + Properties: + Handler: index.handler + Runtime: nodejs12.x + InlineCode: | + exports.handler = async (event) => { + return { + statusCode: 200, + body: JSON.stringify(event), + headers: {} + } + } + Events: + ApiKey: + Type: Api + Properties: + RestApiId: + Ref: MyApiTwo + Method: get + Path: /path/two + ImplicitApiEvent: + Type: Api + Properties: + Method: get + Path: /path/event - MyFunctionThree: - Type: AWS::Serverless::Function - Properties: - Handler: index.handler - Runtime: nodejs12.x - InlineCode: | - exports.handler = async (event) => { - return { - statusCode: 200, - body: JSON.stringify(event), - headers: {} - } - } - Events: - ApiKey: - Type: Api - Properties: - RestApiId: - Ref: MyApiThree - Method: get - Path: /path/three + MyFunctionThree: + Type: AWS::Serverless::Function + Properties: + Handler: index.handler + Runtime: nodejs12.x + InlineCode: | + exports.handler = async (event) => { + return { + statusCode: 200, + body: JSON.stringify(event), + headers: {} + } + } + Events: + ApiKey: + Type: Api + Properties: + RestApiId: + Ref: MyApiThree + Method: get + Path: /path/three Outputs: - ApiOneUrl: - Description: "API endpoint URL for Prod environment" - Value: - Fn::Sub: 'https://${MyApiOne}.execute-api.${AWS::Region}.amazonaws.com/Prod/' - ApiTwoUrl: - Description: "API endpoint URL for Prod environment" - Value: - Fn::Sub: 'https://${MyApiTwo}.execute-api.${AWS::Region}.amazonaws.com/Prod/' - ApiThreeUrl: - Description: "API endpoint URL for Prod environment" - Value: - Fn::Sub: 'https://${MyApiThree}.execute-api.${AWS::Region}.amazonaws.com/Prod/' - UsagePlan: - Description: "Usage Plan physical Id" - Value: - !Ref MyApiTwo.UsagePlan - UsagePlanKey: - Description: "Usage Plan Key" - Value: - !Ref MyApiTwo.UsagePlanKey - ApiKey: - Description: "Api Key" - Value: - !Ref MyApiThree.ApiKey \ No newline at end of file + ApiOneUrl: + Description: API endpoint URL for Prod environment + Value: + Fn::Sub: https://${MyApiOne}.execute-api.${AWS::Region}.amazonaws.com/Prod/ + ApiTwoUrl: + Description: API endpoint URL for Prod environment + Value: + Fn::Sub: https://${MyApiTwo}.execute-api.${AWS::Region}.amazonaws.com/Prod/ + ApiThreeUrl: + Description: API endpoint URL for Prod environment + Value: + Fn::Sub: https://${MyApiThree}.execute-api.${AWS::Region}.amazonaws.com/Prod/ + UsagePlan: + Description: Usage Plan physical Id + Value: !Ref MyApiTwo.UsagePlan + UsagePlanKey: + Description: Usage Plan Key + Value: !Ref MyApiTwo.UsagePlanKey + ApiKey: + Description: Api Key + Value: !Ref MyApiThree.ApiKey diff --git a/tests/functional/commands/validate/lib/models/api_with_usageplans_intrinsics.yaml b/tests/functional/commands/validate/lib/models/api_with_usageplans_intrinsics.yaml index 7a386b556b..7a4190013a 100644 --- a/tests/functional/commands/validate/lib/models/api_with_usageplans_intrinsics.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_usageplans_intrinsics.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- Conditions: C1: Fn::Equals: - - true - - true + - true + - true Parameters: UsagePlanType: @@ -10,76 +12,76 @@ Parameters: Default: PER_API Globals: - Api: - OpenApiVersion: 3.0.0 - Auth: - ApiKeyRequired: true - UsagePlan: - CreateUsagePlan: !Ref UsagePlanType + Api: + OpenApiVersion: 3.0.0 + Auth: + ApiKeyRequired: true + UsagePlan: + CreateUsagePlan: !Ref UsagePlanType Resources: - MyApiOne: - Condition: C1 - Type: AWS::Serverless::Api - Properties: - StageName: Prod + MyApiOne: + Condition: C1 + Type: AWS::Serverless::Api + Properties: + StageName: Prod - MyApiTwo: - Type: AWS::Serverless::Api - Properties: - StageName: Prod + MyApiTwo: + Type: AWS::Serverless::Api + Properties: + StageName: Prod - MyFunctionOne: - Type: AWS::Serverless::Function - Properties: - Handler: index.handler - Runtime: nodejs12.x - InlineCode: | - exports.handler = async (event) => { - return { - statusCode: 200, - body: JSON.stringify(event), - headers: {} - } - } - Events: - ApiKey: - Type: Api - Properties: - RestApiId: - Ref: MyApiOne - Method: get - Path: /path/one + MyFunctionOne: + Type: AWS::Serverless::Function + Properties: + Handler: index.handler + Runtime: nodejs12.x + InlineCode: | + exports.handler = async (event) => { + return { + statusCode: 200, + body: JSON.stringify(event), + headers: {} + } + } + Events: + ApiKey: + Type: Api + Properties: + RestApiId: + Ref: MyApiOne + Method: get + Path: /path/one - MyFunctionTwo: - Type: AWS::Serverless::Function - Properties: - Handler: index.handler - Runtime: nodejs12.x - InlineCode: | - exports.handler = async (event) => { - return { - statusCode: 200, - body: JSON.stringify(event), - headers: {} - } - } - Events: - ApiKey: - Type: Api - Properties: - RestApiId: - Ref: MyApiTwo - Method: get - Path: /path/two + MyFunctionTwo: + Type: AWS::Serverless::Function + Properties: + Handler: index.handler + Runtime: nodejs12.x + InlineCode: | + exports.handler = async (event) => { + return { + statusCode: 200, + body: JSON.stringify(event), + headers: {} + } + } + Events: + ApiKey: + Type: Api + Properties: + RestApiId: + Ref: MyApiTwo + Method: get + Path: /path/two Outputs: - ApiOneUrl: - Description: "API endpoint URL for Prod environment" - Value: - Fn::Sub: 'https://${MyApiOne}.execute-api.${AWS::Region}.amazonaws.com/Prod/' + ApiOneUrl: + Description: API endpoint URL for Prod environment + Value: + Fn::Sub: https://${MyApiOne}.execute-api.${AWS::Region}.amazonaws.com/Prod/ - ApiTwoUrl: - Description: "API endpoint URL for Prod environment" - Value: - Fn::Sub: 'https://${MyApiTwo}.execute-api.${AWS::Region}.amazonaws.com/Prod/' \ No newline at end of file + ApiTwoUrl: + Description: API endpoint URL for Prod environment + Value: + Fn::Sub: https://${MyApiTwo}.execute-api.${AWS::Region}.amazonaws.com/Prod/ diff --git a/tests/functional/commands/validate/lib/models/api_with_usageplans_shared_attributes_three.yaml b/tests/functional/commands/validate/lib/models/api_with_usageplans_shared_attributes_three.yaml index aed811ca0a..aad4a0739d 100644 --- a/tests/functional/commands/validate/lib/models/api_with_usageplans_shared_attributes_three.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_usageplans_shared_attributes_three.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: Api: Auth: @@ -8,12 +10,12 @@ Globals: Conditions: C1: Fn::Equals: - - test - - test + - test + - test C2: Fn::Equals: - - test - - test + - test + - test Resources: MyApiOne: @@ -99,4 +101,4 @@ Resources: RestApiId: Ref: MyApiThree Method: get - Path: /path/three \ No newline at end of file + Path: /path/three diff --git a/tests/functional/commands/validate/lib/models/api_with_usageplans_shared_attributes_two.yaml b/tests/functional/commands/validate/lib/models/api_with_usageplans_shared_attributes_two.yaml index 36c5bab657..fc084c974c 100644 --- a/tests/functional/commands/validate/lib/models/api_with_usageplans_shared_attributes_two.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_usageplans_shared_attributes_two.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: Api: Auth: @@ -8,12 +10,12 @@ Globals: Conditions: C1: Fn::Equals: - - test - - test + - test + - test C2: Fn::Equals: - - test - - test + - test + - test Resources: MyApiOne: @@ -72,4 +74,4 @@ Resources: RestApiId: Ref: MyApiTwo Method: get - Path: /path/two \ No newline at end of file + Path: /path/two diff --git a/tests/functional/commands/validate/lib/models/api_with_usageplans_shared_no_side_effect_1.yaml b/tests/functional/commands/validate/lib/models/api_with_usageplans_shared_no_side_effect_1.yaml index f05fe7511b..f1a25c19b2 100644 --- a/tests/functional/commands/validate/lib/models/api_with_usageplans_shared_no_side_effect_1.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_usageplans_shared_no_side_effect_1.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: Api: Auth: diff --git a/tests/functional/commands/validate/lib/models/api_with_usageplans_shared_no_side_effect_2.yaml b/tests/functional/commands/validate/lib/models/api_with_usageplans_shared_no_side_effect_2.yaml index 857e387692..103be9c802 100644 --- a/tests/functional/commands/validate/lib/models/api_with_usageplans_shared_no_side_effect_2.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_usageplans_shared_no_side_effect_2.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: Api: Auth: diff --git a/tests/functional/commands/validate/lib/models/api_with_xray_tracing.yaml b/tests/functional/commands/validate/lib/models/api_with_xray_tracing.yaml index 8d54a9afc6..48e26405e2 100644 --- a/tests/functional/commands/validate/lib/models/api_with_xray_tracing.yaml +++ b/tests/functional/commands/validate/lib/models/api_with_xray_tracing.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HtmlFunction: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/basic_function.yaml b/tests/functional/commands/validate/lib/models/basic_function.yaml index b7eb77291b..6fdd559225 100644 --- a/tests/functional/commands/validate/lib/models/basic_function.yaml +++ b/tests/functional/commands/validate/lib/models/basic_function.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: SomeParameter: Type: String @@ -7,14 +9,14 @@ Parameters: Default: otherparam Resources: MinimalFunction: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 FunctionWithTracing: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -22,25 +24,25 @@ Resources: Tracing: Active FunctionWithInlineCode: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: - InlineCode: "hello world" + InlineCode: hello world Handler: hello.handler Runtime: python2.7 Tracing: Active FunctionWithCodeUriObject: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: Bucket: somebucket Key: somekey - Version: "1" + Version: '1' Handler: hello.handler Runtime: python2.7 CompleteFunction: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: FunctionName: MyAwesomeFunction CodeUri: s3://sam-demo-bucket/hello.zip @@ -50,63 +52,63 @@ Resources: Timeout: 60 VpcConfig: SecurityGroupIds: - - sg-edcd9784 + - sg-edcd9784 SubnetIds: - - subnet-9d4a7b6c - - subnet-65ea5f08 - - { Ref: SomeParameter } - - { Ref: SomeOtherParameter } + - subnet-9d4a7b6c + - subnet-65ea5f08 + - {Ref: SomeParameter} + - {Ref: SomeOtherParameter} Role: arn:aws:iam::012345678901:role/lambda_basic_execution Environment: Variables: Name: Value Name2: Value2 FunctionWithPolicies: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 Policies: AmazonDynamoDBFullAccess FunctionWithPolicyDocument: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 Policies: Statement: - - Action: ["dynamodb:*"] - Effect: Allow - Resource: "*" + - Action: [dynamodb:*] + Effect: Allow + Resource: '*' FunctionWithRoleRef: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 Role: - Fn::GetAtt: ["MyFunctionRole", "Arn"] + Fn::GetAtt: [MyFunctionRole, Arn] MyFunctionRole: # This is just some role. Actual role definition might be wrong - Type: "AWS::IAM::Role" + Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: - Version: "2012-10-17" + Version: '2012-10-17' Statement: - - Effect: "Allow" - Principal: - Service: - - "ec2.amazonaws.com" - Action: - - "sts:AssumeRole" - Path: "/" + - Effect: Allow + Principal: + Service: + - ec2.amazonaws.com + Action: + - sts:AssumeRole + Path: / Policies: - - PolicyName: "root" - PolicyDocument: - Version: "2012-10-17" - Statement: - - Effect: "Allow" - Action: "*" - Resource: "*" + - PolicyName: root + PolicyDocument: + Version: '2012-10-17' + Statement: + - Effect: Allow + Action: '*' + Resource: '*' diff --git a/tests/functional/commands/validate/lib/models/basic_function_with_tags.yaml b/tests/functional/commands/validate/lib/models/basic_function_with_tags.yaml index 691c1141ec..20c1692071 100644 --- a/tests/functional/commands/validate/lib/models/basic_function_with_tags.yaml +++ b/tests/functional/commands/validate/lib/models/basic_function_with_tags.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- # File: sam.yml # Version: 0.9 @@ -21,8 +23,7 @@ Resources: Timeout: 3 Tags: TagKey1: TagValue1 - TagKey2: "" + TagKey2: '' TagKey3: Ref: TagValueParam - TagKey4: "123" - + TagKey4: '123' diff --git a/tests/functional/commands/validate/lib/models/basic_function_withimageuri.yaml b/tests/functional/commands/validate/lib/models/basic_function_withimageuri.yaml index 897642b555..2a40b5fc96 100644 --- a/tests/functional/commands/validate/lib/models/basic_function_withimageuri.yaml +++ b/tests/functional/commands/validate/lib/models/basic_function_withimageuri.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: SomeParameter: Type: String @@ -7,23 +9,23 @@ Parameters: Default: otherparam Resources: MinimalImageFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: ImageUri: 123456789.dkr.ecr.region.amazonaws.suffix/myimage:latest PackageType: Image MinimalImageFunctionPackageTypeAndImageConfig: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: ImageUri: 123456789.dkr.ecr.region.amazonaws.suffix/myimage:latest PackageType: Image ImageConfig: WorkingDirectory: /var/task Command: /bin/sh - EntryPoint: "echo hello world!" + EntryPoint: echo hello world! CompleteImageFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: FunctionName: MyAwesomeFunction ImageUri: 123456789.dkr.ecr.region.amazonaws.suffix/myimage:latest @@ -42,60 +44,57 @@ Resources: ImageConfig: WorkingDirectory: /var/task Command: /bin/sh - EntryPoint: "echo hello world!" + EntryPoint: echo hello world! Environment: Variables: Name: Value Name2: Value2 FunctionWithPolicies: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: ImageUri: 123456789.dkr.ecr.region.amazonaws.suffix/myimage:latest PackageType: Image Policies: AmazonDynamoDBFullAccess FunctionWithPolicyDocument: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: ImageUri: 123456789.dkr.ecr.region.amazonaws.suffix/myimage:latest PackageType: Image Policies: Statement: - - Action: [ 'dynamodb:*' ] + - Action: [dynamodb:*] Effect: Allow Resource: '*' FunctionWithRoleRef: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: ImageUri: 123456789.dkr.ecr.region.amazonaws.suffix/myimage:latest PackageType: Image Role: - Fn::GetAtt: ["MyFunctionRole", "Arn"] + Fn::GetAtt: [MyFunctionRole, Arn] MyFunctionRole: # This is just some role. Actual role definition might be wrong - Type: "AWS::IAM::Role" + Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: - Version: "2012-10-17" + Version: '2012-10-17' Statement: - - - Effect: "Allow" - Principal: - Service: - - "ec2.amazonaws.com" - Action: - - "sts:AssumeRole" - Path: "/" + - Effect: Allow + Principal: + Service: + - ec2.amazonaws.com + Action: + - sts:AssumeRole + Path: / Policies: - - - PolicyName: "root" - PolicyDocument: - Version: "2012-10-17" - Statement: - - - Effect: "Allow" - Action: "*" - Resource: "*" + - PolicyName: root + PolicyDocument: + Version: '2012-10-17' + Statement: + - Effect: Allow + Action: '*' + Resource: '*' diff --git a/tests/functional/commands/validate/lib/models/basic_layer.yaml b/tests/functional/commands/validate/lib/models/basic_layer.yaml index fa9b5f633f..42f9bd93bb 100644 --- a/tests/functional/commands/validate/lib/models/basic_layer.yaml +++ b/tests/functional/commands/validate/lib/models/basic_layer.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- Conditions: TestCondition: Fn::Equals: - - beta - - beta + - beta + - beta Parameters: DeletePolicy: @@ -11,53 +13,53 @@ Parameters: Resources: MinimalLayer: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: ContentUri: s3://sam-demo-bucket/layer.zip LayerWithContentUriObject: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: ContentUri: Bucket: somebucket Key: somekey - Version: "v1" + Version: v1 RetentionPolicy: Delete CompleteLayer: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: LayerName: MyAwesomeLayer ContentUri: s3://sam-demo-bucket/layer.zip Description: Starter Lambda Layer CompatibleRuntimes: - - python3.6 - - python2.7 - LicenseInfo: "License information" + - python3.6 + - python2.7 + LicenseInfo: License information RetentionPolicy: Retain LayerWithCondition: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Condition: TestCondition Properties: ContentUri: s3://sam-demo-bucket/layer.zip LayerWithCaseInsensitiveRetentionPolicy: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: ContentUri: s3://sam-demo-bucket/layer.zip RetentionPolicy: DeleTe LayerWithRetentionPolicyParam: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: ContentUri: s3://sam-demo-bucket/layer.zip RetentionPolicy: !Ref DeletePolicy LayerWithArchitectures: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: ContentUri: s3://sam-demo-bucket/layer.zip CompatibleArchitectures: - - x86_64 - - arm64 + - x86_64 + - arm64 diff --git a/tests/functional/commands/validate/lib/models/cloudwatch_logs_with_ref.yaml b/tests/functional/commands/validate/lib/models/cloudwatch_logs_with_ref.yaml index b818b66d8b..c9a355981e 100644 --- a/tests/functional/commands/validate/lib/models/cloudwatch_logs_with_ref.yaml +++ b/tests/functional/commands/validate/lib/models/cloudwatch_logs_with_ref.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: Example CloudWatch Logs + Lambda @@ -8,10 +10,10 @@ Parameters: FilterPattern: Type: String Default: My filter pattern - + Resources: TriggeredFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO Handler: hello.handler @@ -22,4 +24,3 @@ Resources: Properties: LogGroupName: !Ref LogGroupName FilterPattern: !Ref FilterPattern - \ No newline at end of file diff --git a/tests/functional/commands/validate/lib/models/cloudwatchevent.yaml b/tests/functional/commands/validate/lib/models/cloudwatchevent.yaml index f14ebcb407..c260907280 100644 --- a/tests/functional/commands/validate/lib/models/cloudwatchevent.yaml +++ b/tests/functional/commands/validate/lib/models/cloudwatchevent.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: ScheduledFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO Handler: hello.handler @@ -9,9 +11,9 @@ Resources: Schedule: Type: Schedule Properties: - Schedule: 'rate(1 minute)' + Schedule: rate(1 minute) TriggeredFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO Handler: hello.handler diff --git a/tests/functional/commands/validate/lib/models/cloudwatchevent_intrinsics.yaml b/tests/functional/commands/validate/lib/models/cloudwatchevent_intrinsics.yaml index 57d0c5893e..59789f5234 100644 --- a/tests/functional/commands/validate/lib/models/cloudwatchevent_intrinsics.yaml +++ b/tests/functional/commands/validate/lib/models/cloudwatchevent_intrinsics.yaml @@ -1,20 +1,22 @@ +%YAML 1.1 +--- Parameters: PathA: Type: String - Default: "SomeInputPath" + Default: SomeInputPath PathB: Type: String - Default: "AnotherInputPath" + Default: AnotherInputPath Conditions: PathCondition: Fn::Equals: - - true - - true + - true + - true Resources: LambdaFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -23,9 +25,9 @@ Resources: OnTerminate: Type: CloudWatchEvent Properties: - EventBusName: !Join [ "", [ "Event", "Bus", "Name" ] ] - Input: !Join [ ":", [ "{ Key", "Value }" ] ] - InputPath: !If [ PathCondition, !Ref PathA, !Ref PathB ] + EventBusName: !Join ['', [Event, Bus, Name]] + Input: !Join [':', ['{ Key', 'Value }']] + InputPath: !If [PathCondition, !Ref PathA, !Ref PathB] Pattern: detail: - state: !Split [ "," , "terminated,stopped" ] \ No newline at end of file + state: !Split [',', 'terminated,stopped'] diff --git a/tests/functional/commands/validate/lib/models/cloudwatchlog.yaml b/tests/functional/commands/validate/lib/models/cloudwatchlog.yaml index 42b2f77151..d85febfa5b 100644 --- a/tests/functional/commands/validate/lib/models/cloudwatchlog.yaml +++ b/tests/functional/commands/validate/lib/models/cloudwatchlog.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: TriggeredFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO Handler: hello.handler @@ -11,4 +13,3 @@ Resources: Properties: LogGroupName: MyCWLogGroup FilterPattern: My filter pattern - diff --git a/tests/functional/commands/validate/lib/models/cognito_userpool_with_event.yaml b/tests/functional/commands/validate/lib/models/cognito_userpool_with_event.yaml index 963bb5e158..3b8a39a929 100644 --- a/tests/functional/commands/validate/lib/models/cognito_userpool_with_event.yaml +++ b/tests/functional/commands/validate/lib/models/cognito_userpool_with_event.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: UserPool: Type: AWS::Cognito::UserPool @@ -7,14 +9,14 @@ Resources: PasswordPolicy: MinimumLength: 8 UsernameAttributes: - - email + - email Schema: - - AttributeDataType: String - Name: email - Required: false + - AttributeDataType: String + Name: email + Required: false UserAttributeUpdateSettings: - AttributesRequireVerificationBeforeUpdate: - - email + AttributesRequireVerificationBeforeUpdate: + - email ImplicitApiFunction: Type: AWS::Serverless::Function Properties: diff --git a/tests/functional/commands/validate/lib/models/congito_userpool_with_sms_configuration.yaml b/tests/functional/commands/validate/lib/models/congito_userpool_with_sms_configuration.yaml index 4677a7b8a4..6265d3a1fd 100644 --- a/tests/functional/commands/validate/lib/models/congito_userpool_with_sms_configuration.yaml +++ b/tests/functional/commands/validate/lib/models/congito_userpool_with_sms_configuration.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HelloWorldFunction: Type: AWS::Serverless::Function @@ -11,13 +13,12 @@ Resources: Properties: UserPool: Ref: MyCognitoUserPool - Trigger: - PreSignUp + Trigger: PreSignUp MyCognitoUserPool: - Type: AWS::Cognito::UserPool - Properties: - UserPoolName: PreSignup - SmsConfiguration: - SnsCallerArn: !GetAtt UserPoolRole.Arn - ExternalId: !Ref ExternalId + Type: AWS::Cognito::UserPool + Properties: + UserPoolName: PreSignup + SmsConfiguration: + SnsCallerArn: !GetAtt UserPoolRole.Arn + ExternalId: !Ref ExternalId diff --git a/tests/functional/commands/validate/lib/models/connector_api_to_function.yaml b/tests/functional/commands/validate/lib/models/connector_api_to_function.yaml index d4fcd8a443..aad57975c1 100644 --- a/tests/functional/commands/validate/lib/models/connector_api_to_function.yaml +++ b/tests/functional/commands/validate/lib/models/connector_api_to_function.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: MyServerlessApi: Type: AWS::Serverless::Api @@ -26,7 +28,7 @@ Resources: RestApiId: !Ref MyApiGateway MyApiGatewayV2: - Type: 'AWS::ApiGatewayV2::Api' + Type: AWS::ApiGatewayV2::Api Properties: Name: MyApi ProtocolType: WEBSOCKET @@ -47,12 +49,12 @@ Resources: Properties: AssumeRolePolicyDocument: Statement: - - Effect: Allow - Action: sts:AssumeRole - Principal: - Service: lambda.amazonaws.com + - Effect: Allow + Action: sts:AssumeRole + Principal: + Service: lambda.amazonaws.com ManagedPolicyArns: - - !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole + - !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole MyFunction: Type: AWS::Lambda::Function @@ -70,39 +72,39 @@ Resources: MyConnectorServerlessApiToLambda: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: MyServerlessApi - Destination: + Destination: Id: MyFunction Permissions: - - Write + - Write MyConnectorApigwToLambda: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: MyApiGateway - Destination: + Destination: Id: MyServerlessFunction Permissions: - - Write + - Write MyConnectorApiV2ToLambda: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: MyApiGatewayV2 - Destination: + Destination: Id: MyServerlessFunction Permissions: - - Write + - Write MyConnectorServerlessHttpApiToLambda: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: MyHttpApi - Destination: + Destination: Id: MyFunction Permissions: - - Write \ No newline at end of file + - Write diff --git a/tests/functional/commands/validate/lib/models/connector_bucket_to_function.yaml b/tests/functional/commands/validate/lib/models/connector_bucket_to_function.yaml index 7853b8b49a..bf8bee626d 100644 --- a/tests/functional/commands/validate/lib/models/connector_bucket_to_function.yaml +++ b/tests/functional/commands/validate/lib/models/connector_bucket_to_function.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: Function: Type: AWS::Serverless::Function @@ -12,14 +14,14 @@ Resources: Bucket: # See also https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfig.html - DependsOn: [MyConnectorWriteLambdaPermission] + DependsOn: MyConnector Type: AWS::S3::Bucket Properties: - BucketName: 'random-bucket-name' + BucketName: random-bucket-name NotificationConfiguration: LambdaConfigurations: - - Event: 's3:ObjectCreated:*' - Function: !GetAtt InvokedFunction.Arn + - Event: s3:ObjectCreated:* + Function: !GetAtt InvokedFunction.Arn MyConnector: Type: AWS::Serverless::Connector @@ -30,4 +32,4 @@ Resources: Destination: Id: Function Permissions: - - Write \ No newline at end of file + - Write diff --git a/tests/functional/commands/validate/lib/models/connector_dependson_replace.yaml b/tests/functional/commands/validate/lib/models/connector_dependson_replace.yaml new file mode 100644 index 0000000000..4bac727840 --- /dev/null +++ b/tests/functional/commands/validate/lib/models/connector_dependson_replace.yaml @@ -0,0 +1,86 @@ +%YAML 1.1 +--- +Transform: AWS::Serverless-2016-10-31 +Resources: + # Stub resources + SomeFunction: + Type: AWS::Lambda::Function + Properties: + Role: !Ref SomeRole + SomeTable: + Type: AWS::DynamoDB::Table + SomeTopic: + Type: AWS::SNS::Topic + SomeQueue: + Type: AWS::SQS::Queue + SomeRule: + Type: AWS::Events::Rule + + # Test AWS_IAM_ROLE_MANAGED_POLICY + IamRolePolicyConnector: + Type: AWS::Serverless::Connector + Properties: + Source: + Id: SomeFunction + Destination: + Id: SomeTable + Permissions: + - Read + - Write + TestIamRolePolicyConnector: + DependsOn: IamRolePolicyConnector + Type: AWS::Foo::Bar + TestIamRolePolicyConnectorMulti: + DependsOn: [Foo, Egg, IamRolePolicyConnector] + Type: AWS::Foo::Bar + + # Test AWS_SNS_TOPIC_POLICY + SnsTopicPolicyConnector: + Type: AWS::Serverless::Connector + Properties: + Source: + Id: SomeRule + Destination: + Id: SomeTopic + Permissions: + - Write + TestSnsTopicPolicyConnector: + DependsOn: SnsTopicPolicyConnector + Type: AWS::Foo::Bar + TestSnsTopicPolicyConnectorMulti: + DependsOn: [Foo, SnsTopicPolicyConnector] + Type: AWS::Foo::Bar + + # Test AWS_LAMBDA_PERMISSION + LambdaPermissionConnector: + Type: AWS::Serverless::Connector + Properties: + Source: + Id: SomeTopic + Destination: + Id: SomeFunction + Permissions: + - Write + TestLambdaPermissionConnector: + DependsOn: LambdaPermissionConnector + Type: AWS::Foo::Bar + TestLambdaPermissionConnectorMulti: + DependsOn: [Foo, LambdaPermissionConnector, Bar] + Type: AWS::Foo::Bar + + # Test AWS_SQS_QUEUE_POLICY + SqsQueuePolicyConnector: + Type: AWS::Serverless::Connector + Properties: + Source: + Id: SomeTopic + Destination: + Id: SomeQueue + Permissions: + - Write + TestSqsQueuePolicyConnector: + DependsOn: SqsQueuePolicyConnector + Type: AWS::Foo::Bar + TestSqsQueuePolicyConnectorMulti: + DependsOn: [SqsQueuePolicyConnector, Foo] + Type: AWS::Foo::Bar diff --git a/tests/functional/commands/validate/lib/models/connector_esm_dependson.yaml b/tests/functional/commands/validate/lib/models/connector_esm_dependson.yaml index 8f6954ec81..76e5d83bd0 100644 --- a/tests/functional/commands/validate/lib/models/connector_esm_dependson.yaml +++ b/tests/functional/commands/validate/lib/models/connector_esm_dependson.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Transform: AWS::Serverless-2016-10-31-test Resources: MyFunction: @@ -47,8 +49,8 @@ Resources: Destination: Id: MyFunction Permissions: - - Write - - Read + - Write + - Read MyConnector2: Type: AWS::Serverless::Connector @@ -58,8 +60,8 @@ Resources: Destination: Id: MyFunction Permissions: - - Read - - Write + - Read + - Write MyConnector3: Type: AWS::Serverless::Connector @@ -69,8 +71,8 @@ Resources: Destination: Id: MyFunction Permissions: - - Read - - Write + - Read + - Write MyConnector4: Type: AWS::Serverless::Connector @@ -80,4 +82,4 @@ Resources: Destination: Id: MyFunction Permissions: - - Read \ No newline at end of file + - Read diff --git a/tests/functional/commands/validate/lib/models/connector_function_to_s3.yaml b/tests/functional/commands/validate/lib/models/connector_function_to_s3.yaml index 2f8d690e1c..637dfe99b6 100644 --- a/tests/functional/commands/validate/lib/models/connector_function_to_s3.yaml +++ b/tests/functional/commands/validate/lib/models/connector_function_to_s3.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: MyFunction: Type: AWS::Serverless::Function @@ -16,10 +18,10 @@ Resources: MyConnector: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: MyFunction - Destination: + Destination: Id: MyBucket Permissions: - - Read - - Write \ No newline at end of file + - Read + - Write diff --git a/tests/functional/commands/validate/lib/models/connector_function_to_sqs.yaml b/tests/functional/commands/validate/lib/models/connector_function_to_sqs.yaml index 5b8462abed..3007387115 100644 --- a/tests/functional/commands/validate/lib/models/connector_function_to_sqs.yaml +++ b/tests/functional/commands/validate/lib/models/connector_function_to_sqs.yaml @@ -1,15 +1,17 @@ +%YAML 1.1 +--- Resources: MyRole: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Statement: - - Effect: Allow - Action: sts:AssumeRole - Principal: - Service: lambda.amazonaws.com + - Effect: Allow + Action: sts:AssumeRole + Principal: + Service: lambda.amazonaws.com ManagedPolicyArns: - - arn:{AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole + - arn:{AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole MyFunction: Type: AWS::Lambda::Function @@ -44,30 +46,30 @@ Resources: MyConnector: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: MyFunction - Destination: + Destination: Id: MyQueue Permissions: - - Read + - Read MyConnectorWithServerlessFunction: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: MyServerlessFunction Destination: Id: MyQueue Permissions: - - Write + - Write MyConnectorWithTwoACs: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: MyFunction - Destination: + Destination: Id: MyQueue Permissions: - - Read - - Write + - Read + - Write diff --git a/tests/functional/commands/validate/lib/models/connector_function_to_table.yaml b/tests/functional/commands/validate/lib/models/connector_function_to_table.yaml index 4a1840c548..461defb06b 100644 --- a/tests/functional/commands/validate/lib/models/connector_function_to_table.yaml +++ b/tests/functional/commands/validate/lib/models/connector_function_to_table.yaml @@ -1,15 +1,17 @@ +%YAML 1.1 +--- Resources: MyRole: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Statement: - - Effect: Allow - Action: sts:AssumeRole - Principal: - Service: lambda.amazonaws.com + - Effect: Allow + Action: sts:AssumeRole + Principal: + Service: lambda.amazonaws.com ManagedPolicyArns: - - arn:{AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole + - arn:{AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole MyFunction: Type: AWS::Lambda::Function @@ -50,11 +52,11 @@ Resources: Properties: BillingMode: PAY_PER_REQUEST AttributeDefinitions: - - AttributeName: "Id" - AttributeType: "S" + - AttributeName: Id + AttributeType: S KeySchema: - - AttributeName: "Id" - KeyType: "HASH" + - AttributeName: Id + KeyType: HASH MyConnector: Type: AWS::Serverless::Connector @@ -64,8 +66,8 @@ Resources: Destination: Id: MyTable Permissions: - - Read - - Read + - Read + - Read MyConnectorWithTableArn: Type: AWS::Serverless::Connector @@ -76,7 +78,7 @@ Resources: Type: AWS::DynamoDB::Table Arn: !GetAtt MyTable.Arn Permissions: - - Read + - Read MyConnectorWith2ACs: Type: AWS::Serverless::Connector @@ -87,8 +89,8 @@ Resources: Type: AWS::DynamoDB::Table Arn: !GetAtt MyTable.Arn Permissions: - - Read - - Write + - Read + - Write MyConnectorWithRoleName: Type: AWS::Serverless::Connector @@ -101,4 +103,4 @@ Resources: Type: AWS::DynamoDB::Table Arn: !GetAtt MyTable.Arn Permissions: - - Read + - Read diff --git a/tests/functional/commands/validate/lib/models/connector_hardcoded_lambda_arn.yaml b/tests/functional/commands/validate/lib/models/connector_hardcoded_lambda_arn.yaml index c003b71052..5aab02a22e 100644 --- a/tests/functional/commands/validate/lib/models/connector_hardcoded_lambda_arn.yaml +++ b/tests/functional/commands/validate/lib/models/connector_hardcoded_lambda_arn.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: MyTopic: Type: AWS::SNS::Topic @@ -11,4 +13,4 @@ Resources: Type: AWS::Lambda::Function Arn: !GetAtt SomeLambda.Arn Permissions: - - Write + - Write diff --git a/tests/functional/commands/validate/lib/models/connector_hardcoded_props.yaml b/tests/functional/commands/validate/lib/models/connector_hardcoded_props.yaml index 6d3aa2f353..ccedcec5cb 100644 --- a/tests/functional/commands/validate/lib/models/connector_hardcoded_props.yaml +++ b/tests/functional/commands/validate/lib/models/connector_hardcoded_props.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Transform: AWS::Serverless-2016-10-31 Resources: # Intentionally not complete @@ -25,7 +27,7 @@ Resources: Type: AWS::SNS::Topic Arn: !GetAtt Egg.Baz Permissions: - - Write + - Write TopicToQueue: Type: AWS::Serverless::Connector @@ -37,7 +39,7 @@ Resources: Arn: !Ref MyQueue QueueUrl: !If [true, !Ref Foo, !Ref Bar] Permissions: - - Write + - Write LambdaToQueue: Type: AWS::Serverless::Connector @@ -49,7 +51,7 @@ Resources: Destination: Id: MyQueue Permissions: - - Write + - Write ApiV1ToLambda: Type: AWS::Serverless::Connector @@ -61,7 +63,7 @@ Resources: Destination: Id: MyFunction Permissions: - - Write + - Write ApiV2ToLambda: Type: AWS::Serverless::Connector @@ -69,11 +71,11 @@ Resources: Source: Type: AWS::ApiGatewayV2::Api ResourceId: !Ref MyApiV2 - Qualifier: "*" + Qualifier: '*' Destination: Id: MyFunction Permissions: - - Write + - Write SfnToSfn: Type: AWS::Serverless::Connector @@ -88,5 +90,5 @@ Resources: Arn: some-other-arn Name: !GetAtt MySfn.Name Permissions: - - Read - - Write \ No newline at end of file + - Read + - Write diff --git a/tests/functional/commands/validate/lib/models/connector_hardcoded_rolename.yaml b/tests/functional/commands/validate/lib/models/connector_hardcoded_rolename.yaml index 36de8b42ea..5ee22d766d 100644 --- a/tests/functional/commands/validate/lib/models/connector_hardcoded_rolename.yaml +++ b/tests/functional/commands/validate/lib/models/connector_hardcoded_rolename.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Transform: AWS::Serverless-2016-10-31 Resources: MyFunction: @@ -18,4 +20,4 @@ Resources: Destination: Id: MyQueue Permissions: - - Write + - Write diff --git a/tests/functional/commands/validate/lib/models/connector_rule_to_eventbus.yaml b/tests/functional/commands/validate/lib/models/connector_rule_to_eventbus.yaml index a4849a5450..df11a58b8b 100644 --- a/tests/functional/commands/validate/lib/models/connector_rule_to_eventbus.yaml +++ b/tests/functional/commands/validate/lib/models/connector_rule_to_eventbus.yaml @@ -1,54 +1,56 @@ +%YAML 1.1 +--- Resources: EventBus: Type: AWS::Events::EventBus - Properties: + Properties: Name: !Sub '${AWS::StackName}-EventBus' MyNewEventsRule: - Type: 'AWS::Events::Rule' + Type: AWS::Events::Rule Properties: Name: mynewabc EventPattern: source: - - aws.ec2 + - aws.ec2 State: ENABLED Targets: - - RoleArn: !GetAtt MyRuleRole.Arn - Arn: !GetAtt 'EventBus.Arn' - Id: EventBus + - RoleArn: !GetAtt MyRuleRole.Arn + Arn: !GetAtt 'EventBus.Arn' + Id: EventBus MyNewEventsRuleToDefaultBus: - Type: 'AWS::Events::Rule' + Type: AWS::Events::Rule Properties: Name: mynewabc EventPattern: source: - - aws.ec2 + - aws.ec2 State: ENABLED Targets: - - RoleArn: !GetAtt MyRuleRole.Arn - Arn: !Sub arn:${AWS::Partition}:events:${AWS::Region}:${AWS::AccountId}:event-bus/default - Id: EventBus + - RoleArn: !GetAtt MyRuleRole.Arn + Arn: !Sub arn:${AWS::Partition}:events:${AWS::Region}:${AWS::AccountId}:event-bus/default + Id: EventBus MyRuleRole: - Type: 'AWS::IAM::Role' + Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Statement: - - Effect: Allow - Principal: - Service: !Sub events.amazonaws.com - Action: 'sts:AssumeRole' + - Effect: Allow + Principal: + Service: !Sub events.amazonaws.com + Action: sts:AssumeRole MyConnector: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: MyNewEventsRule - Destination: + Destination: Id: EventBus Permissions: - - Write + - Write MyConnectorToDefaultBus: Type: AWS::Serverless::Connector @@ -59,4 +61,4 @@ Resources: Type: AWS::Events::EventBus Arn: !Sub arn:${AWS::Partition}:events:${AWS::Region}:${AWS::AccountId}:event-bus/default Permissions: - - Write \ No newline at end of file + - Write diff --git a/tests/functional/commands/validate/lib/models/connector_rule_to_sfn.yaml b/tests/functional/commands/validate/lib/models/connector_rule_to_sfn.yaml index 5456773916..b87e9dbadb 100644 --- a/tests/functional/commands/validate/lib/models/connector_rule_to_sfn.yaml +++ b/tests/functional/commands/validate/lib/models/connector_rule_to_sfn.yaml @@ -1,26 +1,28 @@ +%YAML 1.1 +--- Resources: MyNewEventsRule: - Type: 'AWS::Events::Rule' + Type: AWS::Events::Rule Properties: Name: mynewabc EventPattern: source: - - aws.ec2 + - aws.ec2 State: ENABLED Targets: - - RoleArn: !GetAtt MyRuleRole.Arn - Arn: !GetAtt 'StateMachine.Arn' - Id: StateMachine + - RoleArn: !GetAtt MyRuleRole.Arn + Arn: !GetAtt 'StateMachine.Arn' + Id: StateMachine MyRuleRole: - Type: 'AWS::IAM::Role' + Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Statement: - - Effect: Allow - Principal: - Service: !Sub events.amazonaws.com - Action: 'sts:AssumeRole' + - Effect: Allow + Principal: + Service: !Sub events.amazonaws.com + Action: sts:AssumeRole StateMachine: Type: AWS::Serverless::StateMachine @@ -36,15 +38,15 @@ Resources: Resource: !GetAtt StateMachineFunction.Arn End: true Policies: - - LambdaInvokePolicy: - FunctionName: "SomethingIsNotStateMachineFunction" + - LambdaInvokePolicy: + FunctionName: SomethingIsNotStateMachineFunction MyConnector: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: MyNewEventsRule - Destination: + Destination: Id: StateMachine Permissions: - - Write \ No newline at end of file + - Write diff --git a/tests/functional/commands/validate/lib/models/connector_rule_to_sns.yaml b/tests/functional/commands/validate/lib/models/connector_rule_to_sns.yaml index f7e6495f93..c1a3d27d8d 100644 --- a/tests/functional/commands/validate/lib/models/connector_rule_to_sns.yaml +++ b/tests/functional/commands/validate/lib/models/connector_rule_to_sns.yaml @@ -1,26 +1,28 @@ +%YAML 1.1 +--- Resources: MyNewEventsRule: - Type: 'AWS::Events::Rule' + Type: AWS::Events::Rule Properties: Name: mynewabc EventPattern: source: - - aws.ec2 + - aws.ec2 State: ENABLED Targets: - - RoleArn: !GetAtt MyRuleRole.Arn - Arn: !GetAtt 'StateMachine.Arn' - Id: StateMachine + - RoleArn: !GetAtt MyRuleRole.Arn + Arn: !GetAtt 'StateMachine.Arn' + Id: StateMachine MyRuleRole: - Type: 'AWS::IAM::Role' + Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Statement: - - Effect: Allow - Principal: - Service: !Sub events.amazonaws.com - Action: 'sts:AssumeRole' + - Effect: Allow + Principal: + Service: !Sub events.amazonaws.com + Action: sts:AssumeRole MySNSTopic: Type: AWS::SNS::Topic @@ -28,9 +30,9 @@ Resources: MyConnector: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: MyNewEventsRule - Destination: + Destination: Id: MySNSTopic Permissions: - - Write \ No newline at end of file + - Write diff --git a/tests/functional/commands/validate/lib/models/connector_sfn_to_function.yaml b/tests/functional/commands/validate/lib/models/connector_sfn_to_function.yaml index 52070b5d09..7b18bbca5e 100644 --- a/tests/functional/commands/validate/lib/models/connector_sfn_to_function.yaml +++ b/tests/functional/commands/validate/lib/models/connector_sfn_to_function.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: MyStateMachine: Type: AWS::Serverless::StateMachine @@ -13,8 +15,8 @@ Resources: Resource: !GetAtt StateMachineFunction.Arn End: true Policies: - - LambdaInvokePolicy: - FunctionName: "SomethingIsNotStateMachineFunction" + - LambdaInvokePolicy: + FunctionName: SomethingIsNotStateMachineFunction MyFunction: Type: AWS::Serverless::Function @@ -32,7 +34,7 @@ Resources: Properties: Source: Id: MyStateMachine - Destination: + Destination: Id: MyFunction Permissions: - - Write + - Write diff --git a/tests/functional/commands/validate/lib/models/connector_sfn_to_sfn.yaml b/tests/functional/commands/validate/lib/models/connector_sfn_to_sfn.yaml index b8bb3f9210..289a0c9f23 100644 --- a/tests/functional/commands/validate/lib/models/connector_sfn_to_sfn.yaml +++ b/tests/functional/commands/validate/lib/models/connector_sfn_to_sfn.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: TriggerStateMachine: Type: AWS::Serverless::StateMachine @@ -8,13 +10,13 @@ Resources: States: TryDoSomething: Type: Task - Resource: arn:aws:states:::states:startExecution.sync:2 + Resource: !Sub arn:${AWS::Partition}:states:::states:startExecution.sync:2 Parameters: StateMachineArn: !Ref MyStateMachine - End: True + End: true Policies: - - LambdaInvokePolicy: - FunctionName: "SomethingDoesNotMatter" + - LambdaInvokePolicy: + FunctionName: SomethingDoesNotMatter MyStateMachine: Type: AWS::Serverless::StateMachine @@ -26,8 +28,8 @@ Resources: Success: Type: Succeed Policies: - - LambdaInvokePolicy: - FunctionName: "SomethingDoesNotMatter" + - LambdaInvokePolicy: + FunctionName: SomethingDoesNotMatter MyConnector: Type: AWS::Serverless::Connector @@ -37,5 +39,61 @@ Resources: Destination: Id: MyStateMachine Permissions: - - Read - - Write + - Read + - Write + + StateMachineRole: + Type: AWS::IAM::Role + Properties: + AssumeRolePolicyDocument: + Version: '2012-10-17' + Statement: + - Action: [sts:AssumeRole] + Effect: Allow + Principal: + Service: [states.amazonaws.com] + + TriggerStateMachineWithoutRole: + Type: AWS::Serverless::StateMachine + Properties: + Name: TriggerStateMachineWithoutRole + Role: !GetAtt StateMachineRole.Arn + Definition: + StartAt: Success + States: + Success: + Type: Succeed + + TriggerStateMachineWithoutRole2: + Type: AWS::Serverless::StateMachine + Properties: + Name: TriggerStateMachineWithoutRole + Role: + Fn::GetAtt: StateMachineRole.Arn + Definition: + StartAt: Success + States: + Success: + Type: Succeed + + MyConnectorProvidingRole1: + Type: AWS::Serverless::Connector + Properties: + Source: + Id: TriggerStateMachineWithoutRole + Destination: + Id: MyStateMachine + Permissions: + - Write + - Read + + MyConnectorProvidingRole2: + Type: AWS::Serverless::Connector + Properties: + Source: + Id: TriggerStateMachineWithoutRole2 + Destination: + Id: MyStateMachine + Permissions: + - Write + - Read diff --git a/tests/functional/commands/validate/lib/models/connector_sns_to_function.yaml b/tests/functional/commands/validate/lib/models/connector_sns_to_function.yaml index 60dc7728c3..154698cd15 100644 --- a/tests/functional/commands/validate/lib/models/connector_sns_to_function.yaml +++ b/tests/functional/commands/validate/lib/models/connector_sns_to_function.yaml @@ -1,18 +1,20 @@ +%YAML 1.1 +--- Resources: MySNSTopic: Type: AWS::SNS::Topic - + MyRole: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Statement: - - Effect: Allow - Action: sts:AssumeRole - Principal: - Service: lambda.amazonaws.com + - Effect: Allow + Action: sts:AssumeRole + Principal: + Service: lambda.amazonaws.com ManagedPolicyArns: - - arn:{AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole + - arn:{AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole MyFunction: Type: AWS::Lambda::Function @@ -33,9 +35,9 @@ Resources: MyConnector: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: MySNSTopic - Destination: + Destination: Id: MyFunction Permissions: - - Write \ No newline at end of file + - Write diff --git a/tests/functional/commands/validate/lib/models/connector_sns_to_sqs.yaml b/tests/functional/commands/validate/lib/models/connector_sns_to_sqs.yaml index 8b07ff828f..f6ceab5c0d 100644 --- a/tests/functional/commands/validate/lib/models/connector_sns_to_sqs.yaml +++ b/tests/functional/commands/validate/lib/models/connector_sns_to_sqs.yaml @@ -1,13 +1,15 @@ +%YAML 1.1 +--- Resources: MySNSTopic: Type: AWS::SNS::Topic Properties: Subscription: - - Endpoint: !GetAtt 'MyQueue1.Arn' - Protocol: sqs - - Endpoint: !GetAtt 'MyQueue2.Arn' - Protocol: sqs - + - Endpoint: !GetAtt 'MyQueue1.Arn' + Protocol: sqs + - Endpoint: !GetAtt 'MyQueue2.Arn' + Protocol: sqs + MyQueue1: Type: AWS::SQS::Queue @@ -17,19 +19,19 @@ Resources: MyQueue1Connector: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: MySNSTopic - Destination: + Destination: Id: MyQueue1 Permissions: - - Write + - Write MyQueue2Connector: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: MySNSTopic - Destination: + Destination: Id: MyQueue2 Permissions: - - Write \ No newline at end of file + - Write diff --git a/tests/functional/commands/validate/lib/models/connector_sqs_to_function.yaml b/tests/functional/commands/validate/lib/models/connector_sqs_to_function.yaml index 862d8a9c47..e267d443f0 100644 --- a/tests/functional/commands/validate/lib/models/connector_sqs_to_function.yaml +++ b/tests/functional/commands/validate/lib/models/connector_sqs_to_function.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: Queue: Type: AWS::SQS::Queue @@ -31,10 +33,10 @@ Resources: QUEUE_URL: !Ref Queue VERIFICATION_QUEUE_URL: !Ref VerificationQueue Policies: - - SQSPollerPolicy: - QueueName: !GetAtt VerificationQueue.QueueName - - SQSSendMessagePolicy: - QueueName: !GetAtt Queue.QueueName + - SQSPollerPolicy: + QueueName: !GetAtt VerificationQueue.QueueName + - SQSSendMessagePolicy: + QueueName: !GetAtt Queue.QueueName InvokedFunction: Type: AWS::Serverless::Function @@ -54,17 +56,17 @@ Resources: Variables: VERIFICATION_QUEUE_URL: !Ref VerificationQueue Policies: - - SQSSendMessagePolicy: - QueueName: !GetAtt VerificationQueue.QueueName + - SQSSendMessagePolicy: + QueueName: !GetAtt VerificationQueue.QueueName SQSEventSourceMapping: Type: AWS::Lambda::EventSourceMapping Properties: FunctionName: !Ref InvokedFunction - EventSourceArn: + EventSourceArn: Fn::GetAtt: - - "Queue" - - "Arn" + - Queue + - Arn BatchSize: 10 VerificationQueue: @@ -73,10 +75,10 @@ Resources: Connector: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: Queue - Destination: + Destination: Id: InvokedFunction Permissions: - - Read - - Write + - Read + - Write diff --git a/tests/functional/commands/validate/lib/models/connector_table_to_function.yaml b/tests/functional/commands/validate/lib/models/connector_table_to_function.yaml index edb2e707a7..8c91f2eed7 100644 --- a/tests/functional/commands/validate/lib/models/connector_table_to_function.yaml +++ b/tests/functional/commands/validate/lib/models/connector_table_to_function.yaml @@ -1,15 +1,17 @@ +%YAML 1.1 +--- Resources: MyRole: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Statement: - - Effect: Allow - Action: sts:AssumeRole - Principal: - Service: lambda.amazonaws.com + - Effect: Allow + Action: sts:AssumeRole + Principal: + Service: lambda.amazonaws.com ManagedPolicyArns: - - arn:{AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole + - arn:{AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole MyFunction: Type: AWS::Lambda::Function @@ -34,18 +36,18 @@ Resources: StreamSpecification: StreamViewType: NEW_AND_OLD_IMAGES AttributeDefinitions: - - AttributeName: "Id" - AttributeType: "S" + - AttributeName: Id + AttributeType: S KeySchema: - - AttributeName: "Id" - KeyType: "HASH" + - AttributeName: Id + KeyType: HASH MyConnector: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: MyTable - Destination: + Destination: Id: MyFunction Permissions: - - Read + - Read diff --git a/tests/functional/commands/validate/lib/models/connector_table_to_function_read.yaml b/tests/functional/commands/validate/lib/models/connector_table_to_function_read.yaml index 7e2f5dee83..18ad1647cb 100644 --- a/tests/functional/commands/validate/lib/models/connector_table_to_function_read.yaml +++ b/tests/functional/commands/validate/lib/models/connector_table_to_function_read.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: TriggerFunction: Type: AWS::Serverless::Function @@ -30,8 +32,8 @@ Resources: TABLE_NAME: !Ref Table VERIFICATION_QUEUE_URL: !Ref VerificationQueue Policies: - - SQSPollerPolicy: - QueueName: !GetAtt VerificationQueue.QueueName + - SQSPollerPolicy: + QueueName: !GetAtt VerificationQueue.QueueName InvokedFunction: Type: AWS::Serverless::Function @@ -51,8 +53,8 @@ Resources: Variables: VERIFICATION_QUEUE_URL: !Ref VerificationQueue Policies: - - SQSSendMessagePolicy: - QueueName: !GetAtt VerificationQueue.QueueName + - SQSSendMessagePolicy: + QueueName: !GetAtt VerificationQueue.QueueName VerificationQueue: Type: AWS::SQS::Queue @@ -62,11 +64,11 @@ Resources: Properties: BillingMode: PAY_PER_REQUEST AttributeDefinitions: - - AttributeName: "Id" - AttributeType: "S" + - AttributeName: Id + AttributeType: S KeySchema: - - AttributeName: "Id" - KeyType: "HASH" + - AttributeName: Id + KeyType: HASH StreamSpecification: StreamViewType: NEW_AND_OLD_IMAGES @@ -74,7 +76,7 @@ Resources: Type: AWS::Lambda::EventSourceMapping Properties: BatchSize: 1 - Enabled: True + Enabled: true EventSourceArn: !GetAtt Table.StreamArn FunctionName: !GetAtt InvokedFunction.Arn StartingPosition: TRIM_HORIZON @@ -82,19 +84,19 @@ Resources: Connector: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: Table - Destination: + Destination: Id: InvokedFunction Permissions: - - Read + - Read ConnectorNotTested: Type: AWS::Serverless::Connector Properties: - Source: + Source: Id: TriggerFunction - Destination: + Destination: Id: Table Permissions: - - Write + - Write diff --git a/tests/functional/commands/validate/lib/models/definition_body_intrinsics_support.yaml b/tests/functional/commands/validate/lib/models/definition_body_intrinsics_support.yaml index d082c4f655..65063a7b13 100644 --- a/tests/functional/commands/validate/lib/models/definition_body_intrinsics_support.yaml +++ b/tests/functional/commands/validate/lib/models/definition_body_intrinsics_support.yaml @@ -1,17 +1,22 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > - DefinitionBody currently only supports intrinsics when SwaggerEditor/OpenApiEditor is not used (as of 2022-05-30). - Let's add tests to make sure we keep this support, because we've had a regression where we accidentally + DefinitionBody currently only supports intrinsics when SwaggerEditor/OpenApiEditor + is not used (as of 2022-05-30). + Let's add tests to make sure we keep this support, because we've had a regression + where we accidentally removed this intrinsics support by using the SwaggerEditor. - Note that the only supported intrinsic function for DefinitionBody is Fn::If. Other intrinsics are not supported + Note that the only supported intrinsic function for DefinitionBody is Fn::If. Other + intrinsics are not supported because they don't resolve to dictionary. Conditions: FalseCondition: Fn::Equals: - - true - - false + - true + - false Resources: # Rest Api with DefinitionBody under If intrinsic, SwaggerEditor not used @@ -20,32 +25,30 @@ Resources: Properties: StageName: prod DefinitionBody: - Fn::If: - - FalseCondition - - - swagger: '2.0' - info: - title: !Sub ${AWS::StackName}-Api - paths: - /post: - post: - x-amazon-apigateway-integration: - httpMethod: POST - type: aws_proxy - uri: https://www.alphavantage.co/ - payloadFormatVersion: '1.0' - - - swagger: '2.0' - info: - title: !Sub ${AWS::StackName}-Api - paths: - /post: - post: - x-amazon-apigateway-integration: - httpMethod: POST - type: aws_proxy - uri: https://www.otheruri.co/ - payloadFormatVersion: '1.0' + Fn::If: + - FalseCondition + - swagger: '2.0' + info: + title: !Sub ${AWS::StackName}-Api + paths: + /post: + post: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: https://www.alphavantage.co/ + payloadFormatVersion: '1.0' + - swagger: '2.0' + info: + title: !Sub ${AWS::StackName}-Api + paths: + /post: + post: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: https://www.otheruri.co/ + payloadFormatVersion: '1.0' # HttpApi with DefinitionBody under If intrinsic, OpenApiEditor not used HttpApiIfIntrinsicAndNoOpenApiEditor: @@ -53,29 +56,27 @@ Resources: Properties: StageName: prod DefinitionBody: - Fn::If: - - FalseCondition - - - openapi: '3.0' - info: - title: !Sub ${AWS::StackName}-Api - paths: - /post: - post: - x-amazon-apigateway-integration: - httpMethod: POST - type: aws_proxy - uri: https://www.alphavantage.co/ - payloadFormatVersion: '1.0' - - - openapi: '3.0' - info: - title: !Sub ${AWS::StackName}-Api - paths: - /post: - post: - x-amazon-apigateway-integration: - httpMethod: POST - type: aws_proxy - uri: https://www.otheruri.co/ - payloadFormatVersion: '1.0' + Fn::If: + - FalseCondition + - openapi: '3.0' + info: + title: !Sub ${AWS::StackName}-Api + paths: + /post: + post: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: https://www.alphavantage.co/ + payloadFormatVersion: '1.0' + - openapi: '3.0' + info: + title: !Sub ${AWS::StackName}-Api + paths: + /post: + post: + x-amazon-apigateway-integration: + httpMethod: POST + type: aws_proxy + uri: https://www.otheruri.co/ + payloadFormatVersion: '1.0' diff --git a/tests/functional/commands/validate/lib/models/depends_on.yaml b/tests/functional/commands/validate/lib/models/depends_on.yaml index 34d914a491..f97e011c9e 100644 --- a/tests/functional/commands/validate/lib/models/depends_on.yaml +++ b/tests/functional/commands/validate/lib/models/depends_on.yaml @@ -1,9 +1,11 @@ +%YAML 1.1 +--- # SAM template containing DependsOn property on resources. Output resources should # also have this property set Resources: MyFunction: - Type: 'AWS::Serverless::Function' - DependsOn: ["MyExplicitApi", "MySamTable"] + Type: AWS::Serverless::Function + DependsOn: [MyExplicitApi, MySamTable] Properties: CodeUri: s3://sam-demo-bucket/code.zip Handler: index.handler @@ -18,7 +20,7 @@ Resources: MyExplicitApi: Type: AWS::Serverless::Api - DependsOn: "MySamTable" + DependsOn: MySamTable Properties: DefinitionUri: s3://sam-translator-tests-dont-delete/swagger-http.json StageName: dev @@ -31,18 +33,18 @@ Resources: MyOtherTable: # Test DependsOn property a non-SAM resource Type: AWS::DynamoDB::Table - DependsOn: "MySamTable" + DependsOn: MySamTable Properties: AttributeDefinitions: - - { AttributeName : id, AttributeType : S } + - {AttributeName: id, AttributeType: S} KeySchema: - - { "AttributeName" : "id", "KeyType" : "HASH"} + - {AttributeName: id, KeyType: HASH} ProvisionedThroughput: ReadCapacityUnits: 5 WriteCapacityUnits: 5 StreamSpecification: - StreamViewType: "NEW_IMAGE" + StreamViewType: NEW_IMAGE diff --git a/tests/functional/commands/validate/lib/models/eventbridgerule.yaml b/tests/functional/commands/validate/lib/models/eventbridgerule.yaml index e9006a4641..6ca8660569 100644 --- a/tests/functional/commands/validate/lib/models/eventbridgerule.yaml +++ b/tests/functional/commands/validate/lib/models/eventbridgerule.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: ScheduledFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO Handler: hello.handler @@ -9,9 +11,9 @@ Resources: Schedule: Type: Schedule Properties: - Schedule: 'rate(1 minute)' + Schedule: rate(1 minute) TriggeredFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO Handler: hello.handler diff --git a/tests/functional/commands/validate/lib/models/eventbridgerule_schedule_properties.yaml b/tests/functional/commands/validate/lib/models/eventbridgerule_schedule_properties.yaml index 0c947dfc85..d6d28919fa 100644 --- a/tests/functional/commands/validate/lib/models/eventbridgerule_schedule_properties.yaml +++ b/tests/functional/commands/validate/lib/models/eventbridgerule_schedule_properties.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: ScheduledFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO Handler: hello.handler @@ -9,13 +11,13 @@ Resources: Schedule: Type: Schedule Properties: - Schedule: 'rate(1 minute)' + Schedule: rate(1 minute) Name: test-schedule Description: Test Schedule - Enabled: True + Enabled: true TriggeredFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO Handler: hello.handler diff --git a/tests/functional/commands/validate/lib/models/eventbridgerule_with_dlq.yaml b/tests/functional/commands/validate/lib/models/eventbridgerule_with_dlq.yaml index 7bb7dc59db..e4cbd8e981 100644 --- a/tests/functional/commands/validate/lib/models/eventbridgerule_with_dlq.yaml +++ b/tests/functional/commands/validate/lib/models/eventbridgerule_with_dlq.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: ScheduledFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO Handler: hello.handler @@ -9,11 +11,21 @@ Resources: Schedule: Type: Schedule Properties: - Schedule: 'rate(1 minute)' + Schedule: rate(1 minute) + State: ENABLED DeadLetterConfig: Type: SQS + ScheduleV2: + Type: ScheduleV2 + Properties: + ScheduleExpression: rate(1 minute) + DeadLetterConfig: + Arn: Arn + RetryPolicy: + MaximumRetryAttempts: 5 + MaximumEventAgeInSeconds: 300 TriggeredFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO Handler: hello.handler @@ -23,9 +35,11 @@ Resources: Type: EventBridgeRule Properties: EventBusName: ExternalEventBridge + RuleName: MyRule + State: ENABLED Pattern: detail: state: - terminated DeadLetterConfig: - Arn: ARN \ No newline at end of file + Arn: ARN diff --git a/tests/functional/commands/validate/lib/models/eventbridgerule_with_retry_policy.yaml b/tests/functional/commands/validate/lib/models/eventbridgerule_with_retry_policy.yaml index ed66964aff..93d1d878de 100644 --- a/tests/functional/commands/validate/lib/models/eventbridgerule_with_retry_policy.yaml +++ b/tests/functional/commands/validate/lib/models/eventbridgerule_with_retry_policy.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: ScheduledFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO Handler: hello.handler @@ -9,11 +11,11 @@ Resources: Schedule: Type: Schedule Properties: - Schedule: 'rate(1 minute)' + Schedule: rate(1 minute) RetryPolicy: - MaximumRetryAttempts: 3 + MaximumRetryAttempts: 3 TriggeredFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO Handler: hello.handler @@ -29,4 +31,4 @@ Resources: - terminated RetryPolicy: MaximumRetryAttempts: 3 - MaximumEventAgeInSeconds: 200 \ No newline at end of file + MaximumEventAgeInSeconds: 200 diff --git a/tests/functional/commands/validate/lib/models/explicit_api.yaml b/tests/functional/commands/validate/lib/models/explicit_api.yaml index a2057640cb..34ff9bf54d 100644 --- a/tests/functional/commands/validate/lib/models/explicit_api.yaml +++ b/tests/functional/commands/validate/lib/models/explicit_api.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: MyStageName: Type: String @@ -45,5 +47,5 @@ Resources: StageName: Ref: MyStageName DefinitionBody: - "this": "is" - "a": "inline swagger" + this: is + a: inline swagger diff --git a/tests/functional/commands/validate/lib/models/explicit_api_openapi_3.yaml b/tests/functional/commands/validate/lib/models/explicit_api_openapi_3.yaml index a6f00e5e09..87ebeb8f20 100644 --- a/tests/functional/commands/validate/lib/models/explicit_api_openapi_3.yaml +++ b/tests/functional/commands/validate/lib/models/explicit_api_openapi_3.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: MyStageName: Type: String @@ -46,5 +48,5 @@ Resources: Ref: MyStageName OpenApiVersion: '3.0' DefinitionBody: - "this": "is" - "a": "inline swagger" + this: is + a: inline swagger diff --git a/tests/functional/commands/validate/lib/models/explicit_api_with_invalid_events_config.yaml b/tests/functional/commands/validate/lib/models/explicit_api_with_invalid_events_config.yaml index 2866b5f0c4..33d6f94a90 100644 --- a/tests/functional/commands/validate/lib/models/explicit_api_with_invalid_events_config.yaml +++ b/tests/functional/commands/validate/lib/models/explicit_api_with_invalid_events_config.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- # This is specifically testing a invalid SAM template, that is currently accepted by SAM, and some customers rely on this behavior. # We will eventually change the behavior to error on this invalid template, but until then, this test will guard against # inadvertently changing this behavior. @@ -26,26 +28,7 @@ Resources: Type: AWS::Serverless::Api Properties: StageName: Prod - DefinitionBody: { - "info": { - "version": "1.0", - "title": { - "Ref": "AWS::StackName" - } - }, - "paths": { - "/foo": { - "x-amazon-apigateway-any-method": { - "x-amazon-apigateway-integration": { - "httpMethod": "POST", - "type": "aws_proxy", - "uri": { - "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations" - } - }, - "responses": {} - } - } - }, - "swagger": "2.0" - } + DefinitionBody: {info: {version: '1.0', title: {Ref: AWS::StackName}}, paths: { + /foo: {x-amazon-apigateway-any-method: {x-amazon-apigateway-integration: { + httpMethod: POST, type: aws_proxy, uri: {Fn::Sub: 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations'}}, + responses: {}}}}, swagger: '2.0'} diff --git a/tests/functional/commands/validate/lib/models/explicit_http_api.yaml b/tests/functional/commands/validate/lib/models/explicit_http_api.yaml index 2d50630512..f1bb943784 100644 --- a/tests/functional/commands/validate/lib/models/explicit_http_api.yaml +++ b/tests/functional/commands/validate/lib/models/explicit_http_api.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HttpApiFunction: Type: AWS::Serverless::Function @@ -19,17 +21,17 @@ Resources: MyApi: Type: AWS::Serverless::HttpApi Properties: - FailOnWarnings: True + FailOnWarnings: true Auth: Authorizers: OAuth2: AuthorizationScopes: - - scope4 + - scope4 JwtConfiguration: - issuer: "https://www.example.com/v1/connect/oidc" + issuer: https://www.example.com/v1/connect/oidc audience: - - MyApi - IdentitySource: "$request.querystring.param" + - MyApi + IdentitySource: $request.querystring.param DefaultAuthorizer: OAuth2 MyApi2: @@ -39,10 +41,10 @@ Resources: Authorizers: OAuth2: JwtConfiguration: - issuer: "https://www.example.com/v1/connect/oidc" + issuer: https://www.example.com/v1/connect/oidc audience: - - MyApi - IdentitySource: "$request.querystring.param" + - MyApi + IdentitySource: $request.querystring.param DefaultAuthorizer: OAuth2 DefinitionBody: openapi: '3.0' @@ -59,4 +61,4 @@ Resources: httpMethod: ANY type: http_proxy uri: https://www.alphavantage.co/ - payloadFormatVersion: '1.0' \ No newline at end of file + payloadFormatVersion: '1.0' diff --git a/tests/functional/commands/validate/lib/models/explicit_http_api_default_path.yaml b/tests/functional/commands/validate/lib/models/explicit_http_api_default_path.yaml new file mode 100644 index 0000000000..db2f780f0f --- /dev/null +++ b/tests/functional/commands/validate/lib/models/explicit_http_api_default_path.yaml @@ -0,0 +1,47 @@ +%YAML 1.1 +--- +Transform: AWS::Serverless-2016-10-31 +Resources: + Function: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/todo_list.zip + Handler: index.restapi + Runtime: python3.7 + Events: + HttpApiANYdefault: + Type: HttpApi + Properties: + Path: /$default + Method: ANY + ApiId: !Ref HttpApi + Function2: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/todo_list.zip + Handler: index.restapi + Runtime: python3.7 + Events: + HttpApiANYhello: + Type: HttpApi + Properties: + Path: /hello + Method: ANY + ApiId: !Ref HttpApi + HttpApi: + Type: AWS::Serverless::HttpApi + Properties: + DefinitionBody: + openapi: '3.0' + info: + title: !Sub ${AWS::StackName}-HttpApi + version: '1.0' + paths: + /$default: + x-amazon-apigateway-any-method: + responses: {} + isDefaultRoute: true + /hello: + x-amazon-apigateway-any-method: + responses: {} + FailOnWarnings: true diff --git a/tests/functional/commands/validate/lib/models/explicit_http_api_minimum.yaml b/tests/functional/commands/validate/lib/models/explicit_http_api_minimum.yaml index 9a968d22a4..8aa07e5a75 100644 --- a/tests/functional/commands/validate/lib/models/explicit_http_api_minimum.yaml +++ b/tests/functional/commands/validate/lib/models/explicit_http_api_minimum.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: Api: Type: AWS::Serverless::HttpApi @@ -9,4 +11,4 @@ Resources: Runtime: python3.7 Events: Api: - Type: HttpApi \ No newline at end of file + Type: HttpApi diff --git a/tests/functional/commands/validate/lib/models/function_concurrency.yaml b/tests/functional/commands/validate/lib/models/function_concurrency.yaml index ff39277a4e..b7343a25b9 100644 --- a/tests/functional/commands/validate/lib/models/function_concurrency.yaml +++ b/tests/functional/commands/validate/lib/models/function_concurrency.yaml @@ -1,10 +1,12 @@ +%YAML 1.1 +--- Parameters: Concurrency: Type: Number Resources: ConcurrentFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -12,11 +14,9 @@ Resources: ReservedConcurrentExecutions: 100 AnotherFunction: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 - ReservedConcurrentExecutions: { - "Ref": "Concurrency" - } \ No newline at end of file + ReservedConcurrentExecutions: {Ref: Concurrency} diff --git a/tests/functional/commands/validate/lib/models/function_event_conditions.yaml b/tests/functional/commands/validate/lib/models/function_event_conditions.yaml index f30751333c..b070c16881 100644 --- a/tests/functional/commands/validate/lib/models/function_event_conditions.yaml +++ b/tests/functional/commands/validate/lib/models/function_event_conditions.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- Conditions: MyCondition: Fn::Equals: - - true - - true + - true + - true Resources: @@ -23,7 +25,7 @@ Resources: # All Event Types MyAwesomeFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: MyCondition Properties: CodeUri: s3://sam-demo-bucket/hello.zip @@ -36,7 +38,7 @@ Resources: EBSchedule: Type: Schedule Properties: - Schedule: 'rate(1 minute)' + Schedule: rate(1 minute) CWEvent: Type: CloudWatchEvent diff --git a/tests/functional/commands/validate/lib/models/function_managed_inline_policy.yaml b/tests/functional/commands/validate/lib/models/function_managed_inline_policy.yaml index 538d5f3c69..fd2e45daac 100644 --- a/tests/functional/commands/validate/lib/models/function_managed_inline_policy.yaml +++ b/tests/functional/commands/validate/lib/models/function_managed_inline_policy.yaml @@ -1,26 +1,28 @@ +%YAML 1.1 +--- Parameters: SomeManagedPolicyArn: Type: String Default: arn:aws:iam::aws:policy/OtherPolicy Resources: Function: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 Policies: - - Statement: - - Action: [ 'dynamodb:*' ] - Effect: Allow - Resource: '*' - - AmazonDynamoDBFullAccess + - Statement: + - Action: [dynamodb:*] + Effect: Allow + Resource: '*' + - AmazonDynamoDBFullAccess # Duplicate Policies should get de-duped - - AmazonDynamoDBFullAccess - - AWSLambdaBasicExecutionRole + - AmazonDynamoDBFullAccess + - AWSLambdaBasicExecutionRole - - AWSLambdaRole + - AWSLambdaRole # Intrinsic functions & custom policy ARNs must be supported - - {"Ref": "SomeManagedPolicyArn"} - - arn:aws:iam::123456789012:policy/CustomerCreatedManagedPolicy + - {Ref: SomeManagedPolicyArn} + - arn:aws:iam::123456789012:policy/CustomerCreatedManagedPolicy diff --git a/tests/functional/commands/validate/lib/models/function_with_alias.yaml b/tests/functional/commands/validate/lib/models/function_with_alias.yaml index 4a2defb45e..0844df591b 100644 --- a/tests/functional/commands/validate/lib/models/function_with_alias.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_alias.yaml @@ -1,10 +1,11 @@ +%YAML 1.1 +--- Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 AutoPublishAlias: live VersionDescription: sam-testing - diff --git a/tests/functional/commands/validate/lib/models/function_with_alias_and_code_sha256.yaml b/tests/functional/commands/validate/lib/models/function_with_alias_and_code_sha256.yaml index bec283db1a..b8aa662ccb 100644 --- a/tests/functional/commands/validate/lib/models/function_with_alias_and_code_sha256.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_alias_and_code_sha256.yaml @@ -1,12 +1,14 @@ +%YAML 1.1 +--- Parameters: AutoPublishCodeSha256: - Type: "String" - Description: "Sha256 to uniquely identify creation of the lambda" + Type: String + Description: Sha256 to uniquely identify creation of the lambda Default: 6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -14,4 +16,3 @@ Resources: AutoPublishAlias: live AutoPublishCodeSha256: !Ref AutoPublishCodeSha256 VersionDescription: sam-testing - diff --git a/tests/functional/commands/validate/lib/models/function_with_alias_and_event_sources.yaml b/tests/functional/commands/validate/lib/models/function_with_alias_and_event_sources.yaml index 41a6bc27cc..7dff9c56f5 100644 --- a/tests/functional/commands/validate/lib/models/function_with_alias_and_event_sources.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_alias_and_event_sources.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- # Testing Alias Invoke with ALL event sources supported by Lambda # We are looking to check if the event sources and their associated Lambda::Permission resources are # connect to the Alias and *not* the function @@ -7,7 +9,7 @@ Parameters: Default: beta Resources: MyAwesomeFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -19,7 +21,7 @@ Resources: EBSchedule: Type: Schedule Properties: - Schedule: 'rate(1 minute)' + Schedule: rate(1 minute) CWEvent: Type: CloudWatchEvent @@ -107,4 +109,4 @@ Resources: Key: webpage_swagger.json Variables: LambdaFunction: - Ref: "MyAwesomeFunction" + Ref: MyAwesomeFunction diff --git a/tests/functional/commands/validate/lib/models/function_with_alias_intrinsics.yaml b/tests/functional/commands/validate/lib/models/function_with_alias_intrinsics.yaml index 99327286bf..b2b582f097 100644 --- a/tests/functional/commands/validate/lib/models/function_with_alias_intrinsics.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_alias_intrinsics.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: AliasName: Type: String @@ -5,11 +7,10 @@ Parameters: Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 AutoPublishAlias: Ref: AliasName - diff --git a/tests/functional/commands/validate/lib/models/function_with_amq.yaml b/tests/functional/commands/validate/lib/models/function_with_amq.yaml index 00d28b841a..ea9767a73d 100644 --- a/tests/functional/commands/validate/lib/models/function_with_amq.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_amq.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MQFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/queues.zip Handler: queue.mq_handler @@ -11,7 +13,7 @@ Resources: Properties: Broker: arn:aws:mq:us-east-2:123456789012:broker:MyBroker:b-1234a5b6-78cd-901e-2fgh-3i45j6k178l9 Queues: - - "Queue1" + - Queue1 SourceAccessConfigurations: - - Type: BASIC_AUTH - URI: arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c \ No newline at end of file + - Type: BASIC_AUTH + URI: arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c diff --git a/tests/functional/commands/validate/lib/models/function_with_amq_kms.yaml b/tests/functional/commands/validate/lib/models/function_with_amq_kms.yaml index 7ea02c2dff..6a5bc2c6cc 100644 --- a/tests/functional/commands/validate/lib/models/function_with_amq_kms.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_amq_kms.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MQFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/queues.zip Handler: queue.mq_handler @@ -11,8 +13,8 @@ Resources: Properties: Broker: arn:aws:mq:us-east-2:123456789012:broker:MyBroker:b-1234a5b6-78cd-901e-2fgh-3i45j6k178l9 Queues: - - "Queue1" + - Queue1 SourceAccessConfigurations: - - Type: BASIC_AUTH - URI: arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c - SecretsManagerKmsKeyId: 1abc23d4-567f-8ab9-cde0-1fab234c5d67 \ No newline at end of file + - Type: BASIC_AUTH + URI: arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c + SecretsManagerKmsKeyId: 1abc23d4-567f-8ab9-cde0-1fab234c5d67 diff --git a/tests/functional/commands/validate/lib/models/function_with_architectures.yaml b/tests/functional/commands/validate/lib/models/function_with_architectures.yaml index 81be24492f..4d8af0cd37 100644 --- a/tests/functional/commands/validate/lib/models/function_with_architectures.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_architectures.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- # File: sam.yml # Version: 0.9 @@ -10,7 +12,7 @@ Resources: CodeUri: s3://sam-demo-bucket/hello.zip Description: Created by SAM Handler: index.handler - Architectures: ["arm64"] + Architectures: [arm64] MemorySize: 1024 Runtime: nodejs12.x Timeout: 3 diff --git a/tests/functional/commands/validate/lib/models/function_with_auth_mechanism_for_self_managed_kafka.yaml b/tests/functional/commands/validate/lib/models/function_with_auth_mechanism_for_self_managed_kafka.yaml index 504fd44c08..9ba58b738e 100644 --- a/tests/functional/commands/validate/lib/models/function_with_auth_mechanism_for_self_managed_kafka.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_auth_mechanism_for_self_managed_kafka.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Parameters: {} Resources: KafkaFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/kafka.zip Handler: index.kafka_handler @@ -12,11 +14,10 @@ Resources: Type: SelfManagedKafka Properties: KafkaBootstrapServers: - - "abc.xyz.com:9092" - - "123.45.67.89:9096" + - abc.xyz.com:9092 + - 123.45.67.89:9096 Topics: - - "Topic1" + - Topic1 SourceAccessConfigurations: - - Type: BASIC_AUTH - URI: arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c - + - Type: BASIC_AUTH + URI: arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c diff --git a/tests/functional/commands/validate/lib/models/function_with_condition.yaml b/tests/functional/commands/validate/lib/models/function_with_condition.yaml index 059ea737b4..15842b5418 100644 --- a/tests/functional/commands/validate/lib/models/function_with_condition.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_condition.yaml @@ -1,13 +1,15 @@ +%YAML 1.1 +--- Conditions: TestCondition: Fn::Equals: - - test - - test + - test + - test Resources: ConditionFunction: - Type: 'AWS::Serverless::Function' - Condition: "TestCondition" + Type: AWS::Serverless::Function + Condition: TestCondition Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler - Runtime: python2.7 \ No newline at end of file + Runtime: python2.7 diff --git a/tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy.yaml b/tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy.yaml index 6bfed9d071..02bfab1335 100644 --- a/tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy.yaml @@ -1,6 +1,7 @@ +%YAML 1.1 +--- Conditions: - DummyCondition: - !Equals ["", ""] + DummyCondition: !Equals ['', ''] Resources: FunctionWithConditionalPolicy: @@ -11,7 +12,7 @@ Resources: Runtime: python2.7 CodeUri: s3://sam-demo-bucket/hello.zip Policies: - - !If - - DummyCondition - - !Sub arn:${AWS::Partition}:iam::aws:policy/AdministratorAccess - - !Sub arn:${AWS::Partition}:iam::aws:policy/ReadOnlyAccess \ No newline at end of file + - !If + - DummyCondition + - !Sub arn:${AWS::Partition}:iam::aws:policy/AdministratorAccess + - !Sub arn:${AWS::Partition}:iam::aws:policy/ReadOnlyAccess diff --git a/tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy_and_ref_no_value.yaml b/tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy_and_ref_no_value.yaml index 62f9528016..30f1db3153 100644 --- a/tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy_and_ref_no_value.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_conditional_managed_policy_and_ref_no_value.yaml @@ -1,6 +1,7 @@ +%YAML 1.1 +--- Conditions: - DummyCondition: - !Equals ["", ""] + DummyCondition: !Equals ['', ''] Resources: FunctionWithConditionalPolicy: @@ -11,7 +12,7 @@ Resources: Runtime: python2.7 CodeUri: s3://sam-demo-bucket/hello.zip Policies: - - !If - - DummyCondition - - !Sub arn:${AWS::Partition}:iam::aws:policy/AdministratorAccess - - !Ref "AWS::NoValue" \ No newline at end of file + - !If + - DummyCondition + - !Sub arn:${AWS::Partition}:iam::aws:policy/AdministratorAccess + - !Ref "AWS::NoValue" diff --git a/tests/functional/commands/validate/lib/models/function_with_conditional_policy_template.yaml b/tests/functional/commands/validate/lib/models/function_with_conditional_policy_template.yaml index 4b7a0b8fe9..eda349a65c 100644 --- a/tests/functional/commands/validate/lib/models/function_with_conditional_policy_template.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_conditional_policy_template.yaml @@ -1,6 +1,7 @@ +%YAML 1.1 +--- Conditions: - DummyCondition: - !Equals ["", ""] + DummyCondition: !Equals ['', ''] Resources: FunctionWithConditionalPolicy: @@ -11,9 +12,9 @@ Resources: Runtime: python2.7 CodeUri: s3://sam-demo-bucket/hello.zip Policies: - - !If - - DummyCondition - - AWSSecretsManagerGetSecretValuePolicy: - SecretArn: "Dummy Secret Arn" - - AWSSecretsManagerRotationPolicy: - FunctionName: "Dummy Function Name" \ No newline at end of file + - !If + - DummyCondition + - AWSSecretsManagerGetSecretValuePolicy: + SecretArn: Dummy Secret Arn + - AWSSecretsManagerRotationPolicy: + FunctionName: Dummy Function Name diff --git a/tests/functional/commands/validate/lib/models/function_with_conditional_policy_template_and_ref_no_value.yaml b/tests/functional/commands/validate/lib/models/function_with_conditional_policy_template_and_ref_no_value.yaml index 432b4db2ab..28d169e3dd 100644 --- a/tests/functional/commands/validate/lib/models/function_with_conditional_policy_template_and_ref_no_value.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_conditional_policy_template_and_ref_no_value.yaml @@ -1,6 +1,7 @@ +%YAML 1.1 +--- Conditions: - DummyCondition: - !Equals ["", ""] + DummyCondition: !Equals ['', ''] Resources: FunctionWithConditionalPolicy: @@ -11,8 +12,8 @@ Resources: Runtime: python2.7 CodeUri: s3://sam-demo-bucket/hello.zip Policies: - - !If - - DummyCondition - - AWSSecretsManagerGetSecretValuePolicy: - SecretArn: "Dummy Secret Arn" - - !Ref "AWS::NoValue" \ No newline at end of file + - !If + - DummyCondition + - AWSSecretsManagerGetSecretValuePolicy: + SecretArn: Dummy Secret Arn + - !Ref "AWS::NoValue" diff --git a/tests/functional/commands/validate/lib/models/function_with_custom_codedeploy_deployment_preference.yaml b/tests/functional/commands/validate/lib/models/function_with_custom_codedeploy_deployment_preference.yaml index 1a6a8606a7..b3a46b34df 100644 --- a/tests/functional/commands/validate/lib/models/function_with_custom_codedeploy_deployment_preference.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_custom_codedeploy_deployment_preference.yaml @@ -1,32 +1,32 @@ +%YAML 1.1 +--- Mappings: DeploymentPreferenceMap: prod: - DeploymentPreference: - AllAtOnce + DeploymentPreference: AllAtOnce beta: - DeploymentPreference: - CustomDeployment + DeploymentPreference: CustomDeployment Parameters: Stage: Type: String - Default: 'beta' + Default: beta Deployment: Type: String - Default: 'AllAtOnce' + Default: AllAtOnce Custom: Type: String - Default: 'CustomDeployment' + Default: CustomDeployment Conditions: MyCondition: Fn::Equals: - - true - - false + - true + - false Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -36,7 +36,7 @@ Resources: Type: TestDeploymentConfiguration CustomWithFindInMap: # Doesn't work - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -46,7 +46,7 @@ Resources: Type: !FindInMap [DeploymentPreferenceMap, !Ref Stage, DeploymentPreference] CustomWithCondition: # Works - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -56,7 +56,7 @@ Resources: Type: !If [MyCondition, TestDeploymentConfiguration, AllAtOnce] CustomWithCondition2: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -66,7 +66,7 @@ Resources: Type: !If [MyCondition, !Sub "${Deployment}", !Ref Custom] NormalWithSub: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -76,7 +76,7 @@ Resources: Type: !Sub ${Deployment} CustomWithSub: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -86,11 +86,11 @@ Resources: Type: !Sub ${Custom} NormalWithRef: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 AutoPublishAlias: live DeploymentPreference: - Type: !Ref Deployment \ No newline at end of file + Type: !Ref Deployment diff --git a/tests/functional/commands/validate/lib/models/function_with_custom_conditional_codedeploy_deployment_preference.yaml b/tests/functional/commands/validate/lib/models/function_with_custom_conditional_codedeploy_deployment_preference.yaml index 50bb95e6d8..d4a8cccdfd 100644 --- a/tests/functional/commands/validate/lib/models/function_with_custom_conditional_codedeploy_deployment_preference.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_custom_conditional_codedeploy_deployment_preference.yaml @@ -1,4 +1,6 @@ -AWSTemplateFormatVersion : '2010-09-09' +%YAML 1.1 +--- +AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Parameters: EnvType: @@ -16,4 +18,5 @@ Resources: CodeUri: s3://bucket/key AutoPublishAlias: live DeploymentPreference: - Type: !If [IsDevEnv, !If [IsDevEnv2, AllAtOnce, TestCustomDeploymentConfig], Canary10Percent15Minutes] + Type: !If [IsDevEnv, !If [IsDevEnv2, AllAtOnce, TestCustomDeploymentConfig], + Canary10Percent15Minutes] diff --git a/tests/functional/commands/validate/lib/models/function_with_deployment_and_custom_role.yaml b/tests/functional/commands/validate/lib/models/function_with_deployment_and_custom_role.yaml index 448b0fdc05..fe05e2dcce 100644 --- a/tests/functional/commands/validate/lib/models/function_with_deployment_and_custom_role.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_deployment_and_custom_role.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: Function: AutoPublishAlias: live @@ -7,14 +9,14 @@ Globals: Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 FunctionWithRole: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -35,6 +37,3 @@ Resources: Principal: Service: - codedeploy.amazonaws.com - - - diff --git a/tests/functional/commands/validate/lib/models/function_with_deployment_no_service_role_with_passthrough.yaml b/tests/functional/commands/validate/lib/models/function_with_deployment_no_service_role_with_passthrough.yaml index 6a033caeeb..402af06f8e 100644 --- a/tests/functional/commands/validate/lib/models/function_with_deployment_no_service_role_with_passthrough.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_deployment_no_service_role_with_passthrough.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- Conditions: Condition1: Fn::Equals: - - true - - true + - true + - true Globals: Function: @@ -15,7 +17,7 @@ Globals: Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -23,7 +25,7 @@ Resources: OtherFunction: Condition: Condition1 - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -43,6 +45,3 @@ Resources: Principal: Service: - codedeploy.amazonaws.com - - - diff --git a/tests/functional/commands/validate/lib/models/function_with_deployment_no_service_role_without_passthrough.yaml b/tests/functional/commands/validate/lib/models/function_with_deployment_no_service_role_without_passthrough.yaml index ef92307c8e..5216220895 100644 --- a/tests/functional/commands/validate/lib/models/function_with_deployment_no_service_role_without_passthrough.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_deployment_no_service_role_without_passthrough.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- Conditions: Condition1: Fn::Equals: - - true - - true + - true + - true Globals: Function: @@ -14,7 +16,7 @@ Globals: Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -22,7 +24,7 @@ Resources: OtherFunction: Condition: Condition1 - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -42,6 +44,3 @@ Resources: Principal: Service: - codedeploy.amazonaws.com - - - diff --git a/tests/functional/commands/validate/lib/models/function_with_deployment_preference.yaml b/tests/functional/commands/validate/lib/models/function_with_deployment_preference.yaml index d3d5f47d25..7550f4316a 100644 --- a/tests/functional/commands/validate/lib/models/function_with_deployment_preference.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_deployment_preference.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: FnName: Type: String @@ -7,14 +9,15 @@ Parameters: EnableAliasProvisionedConcurrency: Type: String AllowedValues: - - true - - false + - true + - false Default: true Conditions: - AliasProvisionedConcurrencyEnabled: !Equals [!Ref EnableAliasProvisionedConcurrency, true] + AliasProvisionedConcurrencyEnabled: !Equals [!Ref EnableAliasProvisionedConcurrency, + true] Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -23,6 +26,6 @@ Resources: DeploymentPreference: Type: Linear10PercentEvery3Minutes ProvisionedConcurrencyConfig: !If - - AliasProvisionedConcurrencyEnabled - - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency - - !Ref 'AWS::NoValue' + - AliasProvisionedConcurrencyEnabled + - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency + - !Ref 'AWS::NoValue' diff --git a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_alarms_intrinsic_if.yaml b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_alarms_intrinsic_if.yaml index f392f10628..a63e9bc3a8 100644 --- a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_alarms_intrinsic_if.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_alarms_intrinsic_if.yaml @@ -1,11 +1,13 @@ +%YAML 1.1 +--- Conditions: MyCondition: Fn::Equals: - - true - - false + - true + - false Resources: MinimalFunction: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -15,9 +17,9 @@ Resources: Type: Linear10PercentEvery3Minutes Alarms: Fn::If: - - MyCondition - - - Alarm1 - - Alarm2 - - Alarm3 - - - Alarm1 - - Alarm5 + - MyCondition + - - Alarm1 + - Alarm2 + - Alarm3 + - - Alarm1 + - Alarm5 diff --git a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_all_parameters.yaml b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_all_parameters.yaml index cbbc80e5f7..8bd803ffcb 100644 --- a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_all_parameters.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_all_parameters.yaml @@ -1,53 +1,55 @@ +%YAML 1.1 +--- Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 AutoPublishAlias: live DeploymentPreference: - Enabled: True + Enabled: true Type: Linear10PercentEvery1Minute Hooks: PreTraffic: !Ref MySanityTestFunction PostTraffic: !Ref MyValidationTestFunction Alarms: - - !Ref MyCloudWatchAlarm + - !Ref MyCloudWatchAlarm TriggerConfigurations: - - TriggerEvents: - - DeploymentSuccess - - DeploymentFailure - TriggerName: TestTrigger - TriggerTargetArn: !Ref MySNSTopic + - TriggerEvents: + - DeploymentSuccess + - DeploymentFailure + TriggerName: TestTrigger + TriggerTargetArn: !Ref MySNSTopic MySanityTestFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: Handler: hello.handler Runtime: python2.7 CodeUri: s3://my-bucket/mySanityTestFunction.zip DeploymentPreference: - Enabled: False + Enabled: false MyValidationTestFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: Handler: hello.handler Runtime: python2.7 CodeUri: s3://my-bucket/myValidationTestFunction.zip DeploymentPreference: - Enabled: False + Enabled: false MyCloudWatchAlarm: Type: AWS::CloudWatch::Alarm Properties: - ComparisonOperator: GreaterThanThreshold - EvaluationPeriods: 1 - MetricName: MyMetric - Namespace: AWS/EC2 - Period: 300 - Threshold: 10 + ComparisonOperator: GreaterThanThreshold + EvaluationPeriods: 1 + MetricName: MyMetric + Namespace: AWS/EC2 + Period: 300 + Threshold: 10 MySNSTopic: - Type: AWS::SNS::Topic \ No newline at end of file + Type: AWS::SNS::Topic diff --git a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_condition_with_passthrough.yaml b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_condition_with_passthrough.yaml index b112e4d300..3f36716080 100644 --- a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_condition_with_passthrough.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_condition_with_passthrough.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: FnName: Type: String @@ -7,15 +9,16 @@ Parameters: EnableAliasProvisionedConcurrency: Type: String AllowedValues: - - true - - false + - true + - false Default: true Conditions: - AliasProvisionedConcurrencyEnabled: !Equals [!Ref EnableAliasProvisionedConcurrency, true] + AliasProvisionedConcurrencyEnabled: !Equals [!Ref EnableAliasProvisionedConcurrency, + true] FunctionCondition: !Equals [true, true] Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: FunctionCondition Properties: CodeUri: s3://sam-demo-bucket/hello.zip @@ -26,6 +29,6 @@ Resources: Type: Linear10PercentEvery3Minutes PassthroughCondition: true ProvisionedConcurrencyConfig: !If - - AliasProvisionedConcurrencyEnabled - - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency - - !Ref 'AWS::NoValue' + - AliasProvisionedConcurrencyEnabled + - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency + - !Ref 'AWS::NoValue' diff --git a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_condition_without_passthrough.yaml b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_condition_without_passthrough.yaml index 06e788bfec..9ecf17ceec 100644 --- a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_condition_without_passthrough.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_condition_without_passthrough.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: FnName: Type: String @@ -7,15 +9,16 @@ Parameters: EnableAliasProvisionedConcurrency: Type: String AllowedValues: - - true - - false + - true + - false Default: true Conditions: - AliasProvisionedConcurrencyEnabled: !Equals [!Ref EnableAliasProvisionedConcurrency, true] + AliasProvisionedConcurrencyEnabled: !Equals [!Ref EnableAliasProvisionedConcurrency, + true] FunctionCondition: !Equals [true, true] Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: FunctionCondition Properties: CodeUri: s3://sam-demo-bucket/hello.zip @@ -25,6 +28,6 @@ Resources: DeploymentPreference: Type: Linear10PercentEvery3Minutes ProvisionedConcurrencyConfig: !If - - AliasProvisionedConcurrencyEnabled - - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency - - !Ref 'AWS::NoValue' \ No newline at end of file + - AliasProvisionedConcurrencyEnabled + - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency + - !Ref 'AWS::NoValue' diff --git a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_from_parameters.yaml b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_from_parameters.yaml index b77580f9be..788709cfbe 100644 --- a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_from_parameters.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_from_parameters.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: MyTrueParameter: Default: 'True' @@ -11,7 +13,7 @@ Parameters: Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -24,16 +26,16 @@ Resources: PreTraffic: !Ref MySanityTestFunction PostTraffic: !Ref MyValidationTestFunction Alarms: - - !Ref MyCloudWatchAlarm + - !Ref MyCloudWatchAlarm TriggerConfigurations: - - TriggerEvents: - - DeploymentSuccess - - DeploymentFailure - TriggerName: TestTrigger - TriggerTargetArn: !Ref MySNSTopic + - TriggerEvents: + - DeploymentSuccess + - DeploymentFailure + TriggerName: TestTrigger + TriggerTargetArn: !Ref MySNSTopic MySanityTestFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: Handler: hello.handler Runtime: python2.7 @@ -42,7 +44,7 @@ Resources: Enabled: !Ref MyLowerFalseParameter MyValidationTestFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: Handler: hello.handler Runtime: python2.7 @@ -53,12 +55,12 @@ Resources: MyCloudWatchAlarm: Type: AWS::CloudWatch::Alarm Properties: - ComparisonOperator: GreaterThanThreshold - EvaluationPeriods: 1 - MetricName: MyMetric - Namespace: AWS/EC2 - Period: 300 - Threshold: 10 + ComparisonOperator: GreaterThanThreshold + EvaluationPeriods: 1 + MetricName: MyMetric + Namespace: AWS/EC2 + Period: 300 + Threshold: 10 MySNSTopic: - Type: AWS::SNS::Topic \ No newline at end of file + Type: AWS::SNS::Topic diff --git a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_multiple_combinations.yaml b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_multiple_combinations.yaml index 9cc5703d8a..66093db147 100644 --- a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_multiple_combinations.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_multiple_combinations.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -8,7 +10,7 @@ Resources: AutoPublishAlias: live MinimalFunctionWithMinimalDeploymentPreference: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -18,7 +20,7 @@ Resources: Type: Canary10Percent5Minutes MinimalFunctionWithDeploymentPreferenceWithHooksAndAlarms: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -30,32 +32,32 @@ Resources: PreTraffic: !Ref MySanityTestFunction PostTraffic: !Ref MyValidationTestFunction Alarms: - - !Ref MyCloudWatchAlarm + - !Ref MyCloudWatchAlarm MySanityTestFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: Handler: hello.handler Runtime: python2.7 CodeUri: s3://my-bucket/mySanityTestFunction.zip DeploymentPreference: - Enabled: False + Enabled: false MyValidationTestFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: Handler: hello.handler Runtime: python2.7 CodeUri: s3://my-bucket/myValidationTestFunction.zip DeploymentPreference: - Enabled: False + Enabled: false MyCloudWatchAlarm: Type: AWS::CloudWatch::Alarm Properties: - ComparisonOperator: GreaterThanThreshold - EvaluationPeriods: 1 - MetricName: MyMetric - Namespace: AWS/EC2 - Period: 300 - Threshold: 10 + ComparisonOperator: GreaterThanThreshold + EvaluationPeriods: 1 + MetricName: MyMetric + Namespace: AWS/EC2 + Period: 300 + Threshold: 10 diff --git a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_multiple_combinations_conditions_with_passthrough.yaml b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_multiple_combinations_conditions_with_passthrough.yaml index 78445ec100..9d98ad8de6 100644 --- a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_multiple_combinations_conditions_with_passthrough.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_multiple_combinations_conditions_with_passthrough.yaml @@ -1,26 +1,28 @@ +%YAML 1.1 +--- Conditions: Condition1: Fn::Equals: - - true - - true + - true + - true Condition2: Fn::Equals: - - true - - false + - true + - false Condition3: Fn::Equals: - - true - - false + - true + - false Parameters: MyFalseParameter: Type: String - Default: False + Default: false Resources: MinimalFunction: Condition: Condition1 - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -31,7 +33,7 @@ Resources: PassthroughCondition: true MinimalFunctionWithMinimalDeploymentPreference: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Condition2 Properties: CodeUri: s3://sam-demo-bucket/hello.zip @@ -43,7 +45,7 @@ Resources: PassthroughCondition: true MinimalFunctionWithDeploymentPreferenceWithHooksAndAlarms: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Condition2 Properties: CodeUri: s3://sam-demo-bucket/hello.zip @@ -56,22 +58,22 @@ Resources: PreTraffic: !Ref MySanityTestFunction PostTraffic: !Ref MyValidationTestFunction Alarms: - - !Ref MyCloudWatchAlarm + - !Ref MyCloudWatchAlarm PassthroughCondition: true MySanityTestFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Condition3 Properties: Handler: hello.handler Runtime: python2.7 CodeUri: s3://my-bucket/mySanityTestFunction.zip DeploymentPreference: - Enabled: False + Enabled: false PassthroughCondition: true MyValidationTestFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: Handler: hello.handler Runtime: python2.7 diff --git a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_multiple_combinations_conditions_without_passthrough.yaml b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_multiple_combinations_conditions_without_passthrough.yaml index f9e994109a..6e4bcf1204 100644 --- a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_multiple_combinations_conditions_without_passthrough.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_multiple_combinations_conditions_without_passthrough.yaml @@ -1,26 +1,28 @@ +%YAML 1.1 +--- Conditions: Condition1: Fn::Equals: - - true - - true + - true + - true Condition2: Fn::Equals: - - true - - false + - true + - false Condition3: Fn::Equals: - - true - - false + - true + - false Parameters: MyFalseParameter: Type: String - Default: False + Default: false Resources: MinimalFunction: Condition: Condition1 - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -30,7 +32,7 @@ Resources: Type: Linear10PercentEvery2Minutes MinimalFunctionWithMinimalDeploymentPreference: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Condition2 Properties: CodeUri: s3://sam-demo-bucket/hello.zip @@ -41,7 +43,7 @@ Resources: Type: Canary10Percent5Minutes MinimalFunctionWithDeploymentPreferenceWithHooksAndAlarms: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Condition2 Properties: CodeUri: s3://sam-demo-bucket/hello.zip @@ -54,20 +56,20 @@ Resources: PreTraffic: !Ref MySanityTestFunction PostTraffic: !Ref MyValidationTestFunction Alarms: - - !Ref MyCloudWatchAlarm + - !Ref MyCloudWatchAlarm MySanityTestFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Condition3 Properties: Handler: hello.handler Runtime: python2.7 CodeUri: s3://my-bucket/mySanityTestFunction.zip DeploymentPreference: - Enabled: False + Enabled: false MyValidationTestFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: Handler: hello.handler Runtime: python2.7 diff --git a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_passthrough_condition_with_supported_intrinsics.yaml b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_passthrough_condition_with_supported_intrinsics.yaml index 0c438d5547..b1efee4b48 100644 --- a/tests/functional/commands/validate/lib/models/function_with_deployment_preference_passthrough_condition_with_supported_intrinsics.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_deployment_preference_passthrough_condition_with_supported_intrinsics.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- # Tests supported intrinsics in the PassthroughCondition property Mappings: @@ -18,29 +20,30 @@ Parameters: EnableAliasProvisionedConcurrency: Type: String AllowedValues: - - true - - false + - true + - false Default: true DefaultTrueParam: Type: String - Default: "true" + Default: 'true' DefaultFalseParam: Type: String - Default: "false" + Default: 'false' HelloParam: Type: String - Default: "hello" + Default: hello WorldParam: Type: String - Default: "world" + Default: world Conditions: - AliasProvisionedConcurrencyEnabled: !Equals [!Ref EnableAliasProvisionedConcurrency, true] + AliasProvisionedConcurrencyEnabled: !Equals [!Ref EnableAliasProvisionedConcurrency, + true] FunctionCondition: !Equals [true, true] Resources: TrueRef: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: FunctionCondition Properties: CodeUri: s3://sam-demo-bucket/hello.zip @@ -51,12 +54,11 @@ Resources: Type: Linear10PercentEvery3Minutes PassthroughCondition: !Ref DefaultTrueParam ProvisionedConcurrencyConfig: !If - - AliasProvisionedConcurrencyEnabled - - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency - - !Ref 'AWS::NoValue' - + - AliasProvisionedConcurrencyEnabled + - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency + - !Ref 'AWS::NoValue' FalseRef: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: FunctionCondition Properties: CodeUri: s3://sam-demo-bucket/hello.zip @@ -65,14 +67,13 @@ Resources: AutoPublishAlias: live DeploymentPreference: Type: Linear10PercentEvery3Minutes - PassthroughCondition: !Ref DefaultFalseParam + PassthroughCondition: !Ref DefaultFalseParam ProvisionedConcurrencyConfig: !If - - AliasProvisionedConcurrencyEnabled - - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency - - !Ref 'AWS::NoValue' - + - AliasProvisionedConcurrencyEnabled + - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency + - !Ref 'AWS::NoValue' TrueFindInMap: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: FunctionCondition Properties: CodeUri: s3://sam-demo-bucket/hello.zip @@ -82,16 +83,15 @@ Resources: DeploymentPreference: Type: Linear10PercentEvery3Minutes PassthroughCondition: !FindInMap - - HelloWorldMap - - !Ref HelloParam - - key1 + - HelloWorldMap + - !Ref HelloParam + - key1 ProvisionedConcurrencyConfig: !If - - AliasProvisionedConcurrencyEnabled - - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency - - !Ref 'AWS::NoValue' - + - AliasProvisionedConcurrencyEnabled + - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency + - !Ref 'AWS::NoValue' FalseFindInMap: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: FunctionCondition Properties: CodeUri: s3://sam-demo-bucket/hello.zip @@ -101,10 +101,10 @@ Resources: DeploymentPreference: Type: Linear10PercentEvery3Minutes PassthroughCondition: !FindInMap - - HelloWorldMap - - !Ref WorldParam - - key1 + - HelloWorldMap + - !Ref WorldParam + - key1 ProvisionedConcurrencyConfig: !If - - AliasProvisionedConcurrencyEnabled - - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency - - !Ref 'AWS::NoValue' \ No newline at end of file + - AliasProvisionedConcurrencyEnabled + - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency + - !Ref 'AWS::NoValue' diff --git a/tests/functional/commands/validate/lib/models/function_with_disabled_deployment_preference.yaml b/tests/functional/commands/validate/lib/models/function_with_disabled_deployment_preference.yaml index 26b7dc8e14..07f8335f22 100644 --- a/tests/functional/commands/validate/lib/models/function_with_disabled_deployment_preference.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_disabled_deployment_preference.yaml @@ -1,11 +1,13 @@ +%YAML 1.1 +--- Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 AutoPublishAlias: live DeploymentPreference: - Enabled: False + Enabled: false Type: AllAtOnce diff --git a/tests/functional/commands/validate/lib/models/function_with_disabled_traffic_hook.yaml b/tests/functional/commands/validate/lib/models/function_with_disabled_traffic_hook.yaml index ff37cc0559..65a9281f48 100644 --- a/tests/functional/commands/validate/lib/models/function_with_disabled_traffic_hook.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_disabled_traffic_hook.yaml @@ -1,6 +1,9 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 -Description: Template with preference that does not require a new CodeDeploy Service Role +Description: Template with preference that does not require a new CodeDeploy Service + Role Resources: @@ -35,7 +38,7 @@ Resources: Fn::Sub: arn:${AWS::Partition}:iam::${AWS::AccountId}:role/lambda-role Runtime: python3.7 CodeUri: s3://bucket/key - FunctionName: 'CodeDeployHook_preTrafficHook' + FunctionName: CodeDeployHook_preTrafficHook AutoPublishAlias: live DeploymentPreference: Enabled: false @@ -44,4 +47,4 @@ Resources: Environment: Variables: NewVersion: - Ref: Function.Version \ No newline at end of file + Ref: Function.Version diff --git a/tests/functional/commands/validate/lib/models/function_with_dlq.yaml b/tests/functional/commands/validate/lib/models/function_with_dlq.yaml index 217777345b..5567d4935c 100644 --- a/tests/functional/commands/validate/lib/models/function_with_dlq.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_dlq.yaml @@ -1,4 +1,6 @@ -Transform: "AWS::Serverless-2016-10-31" +%YAML 1.1 +--- +Transform: AWS::Serverless-2016-10-31 Resources: MySnsDlqLambdaFunction: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/function_with_ephemeral_storage.yaml b/tests/functional/commands/validate/lib/models/function_with_ephemeral_storage.yaml index 97177a3c88..beae97b5e2 100644 --- a/tests/functional/commands/validate/lib/models/function_with_ephemeral_storage.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_ephemeral_storage.yaml @@ -1,20 +1,22 @@ +%YAML 1.1 +--- Parameters: EphemeralStorageSizeRef: Type: Number Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 - EphemeralStorage: + EphemeralStorage: Size: 1024 FunctionWithIntrinsicRef: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 - EphemeralStorage: - Size: !Ref EphemeralStorageSizeRef \ No newline at end of file + EphemeralStorage: + Size: !Ref EphemeralStorageSizeRef diff --git a/tests/functional/commands/validate/lib/models/function_with_event_bridge_rule_state.yaml b/tests/functional/commands/validate/lib/models/function_with_event_bridge_rule_state.yaml index b4d7720d24..221a8962f2 100644 --- a/tests/functional/commands/validate/lib/models/function_with_event_bridge_rule_state.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_event_bridge_rule_state.yaml @@ -1,4 +1,6 @@ -Transform: "AWS::Serverless-2016-10-31" +%YAML 1.1 +--- +Transform: AWS::Serverless-2016-10-31 Resources: TestBucket: @@ -6,7 +8,7 @@ Resources: Properties: BucketName: test-bucket TestFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: FunctionName: test-function InlineCode: | @@ -22,13 +24,13 @@ Resources: State: ENABLED Pattern: source: - - aws.s3 + - aws.s3 detail-type: - - Object Created + - Object Created detail: bucket: name: - - "test-bucket" + - test-bucket object: key: - - prefix: "/" \ No newline at end of file + - prefix: / diff --git a/tests/functional/commands/validate/lib/models/function_with_event_dest.yaml b/tests/functional/commands/validate/lib/models/function_with_event_dest.yaml index 23e1a75248..3c58d6c04a 100644 --- a/tests/functional/commands/validate/lib/models/function_with_event_dest.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_event_dest.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: SQSArn: Type: String @@ -5,14 +7,14 @@ Parameters: UseExistingQueue: Type: String AllowedValues: - - true - - false + - true + - false Default: true CreateSNSTopic: Type: String AllowedValues: - - true - - false + - true + - false Default: true Conditions: QueueCreationDisabled: !Equals [!Ref UseExistingQueue, true] @@ -28,9 +30,9 @@ Resources: OnSuccess: Type: SQS Destination: !If [QueueCreationDisabled, !Ref SQSArn, !Ref 'AWS::NoValue'] - OnFailure: + OnFailure: Type: SNS - Destination: !If [TopicCreationEnabled, !Ref 'AWS::NoValue', 'SOME-SNS-ARN'] + Destination: !If [TopicCreationEnabled, !Ref 'AWS::NoValue', SOME-SNS-ARN] InlineCode: | exports.handler = function(event, context, callback) { var event_received_at = new Date().toISOString(); @@ -60,7 +62,7 @@ Resources: OnSuccess: Type: Lambda Destination: !GetAtt DestinationLambda.Arn - OnFailure: + OnFailure: Type: EventBridge Destination: event-bus-arn InlineCode: | @@ -100,7 +102,7 @@ Resources: SNSSubscription: Type: AWS::SNS::Subscription Condition: TopicCreationEnabled - Properties: + Properties: Endpoint: example@example.com Protocol: email - TopicArn: !Ref MyTestFunction.DestinationTopic + TopicArn: !Ref MyTestFunction.DestinationTopic diff --git a/tests/functional/commands/validate/lib/models/function_with_event_dest_basic.yaml b/tests/functional/commands/validate/lib/models/function_with_event_dest_basic.yaml index e26b320597..6e6f7bb892 100644 --- a/tests/functional/commands/validate/lib/models/function_with_event_dest_basic.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_event_dest_basic.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: SNSArn: Type: String @@ -11,7 +13,7 @@ Globals: DestinationConfig: OnSuccess: Type: SQS - OnFailure: + OnFailure: Type: SNS Destination: !Ref SNSArn diff --git a/tests/functional/commands/validate/lib/models/function_with_event_dest_conditional.yaml b/tests/functional/commands/validate/lib/models/function_with_event_dest_conditional.yaml index 45e1b69e14..22a4d73c1c 100644 --- a/tests/functional/commands/validate/lib/models/function_with_event_dest_conditional.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_event_dest_conditional.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: SQSArn: Type: String @@ -5,8 +7,8 @@ Parameters: UseExistingQueue: Type: String AllowedValues: - - true - - false + - true + - false Default: true Conditions: QueueCreationDisabled: !Equals [!Ref UseExistingQueue, true] @@ -24,9 +26,10 @@ Resources: OnSuccess: Type: SQS Destination: !If [QueueCreationDisabled, !Ref SQSArn, !Ref 'AWS::NoValue'] - OnFailure: + OnFailure: Type: Lambda - Destination: !If [FunctionInlineEnabled, !GetAtt DestinationLambda.Arn, 'some-function-arn'] + Destination: !If [FunctionInlineEnabled, !GetAtt DestinationLambda.Arn, + some-function-arn] InlineCode: | exports.handler = function(event, context, callback) { var event_received_at = new Date().toISOString(); diff --git a/tests/functional/commands/validate/lib/models/function_with_event_filtering.yaml b/tests/functional/commands/validate/lib/models/function_with_event_filtering.yaml index 32af438134..b54390fa60 100644 --- a/tests/functional/commands/validate/lib/models/function_with_event_filtering.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_event_filtering.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: FilteredEventsFunction: Type: AWS::Serverless::Function @@ -13,8 +15,8 @@ Resources: StartingPosition: LATEST FilterCriteria: Filters: - - Pattern: '{"name": "value"}' - - Pattern: '{"name2": "value2"}' + - Pattern: '{"name": "value"}' + - Pattern: '{"name2": "value2"}' DynamoDBStreamEvent: Type: DynamoDB Properties: @@ -22,60 +24,55 @@ Resources: StartingPosition: TRIM_HORIZON FilterCriteria: Filters: - - Pattern: '{ - "dynamodb": { - "NewImage": { - "value": { "S": ["test"] } - } - } - }' + - Pattern: '{ "dynamodb": { "NewImage": { "value": { "S": ["test"] } + } } }' MySqsEvent: Type: SQS Properties: Queue: !GetAtt MySqsQueue.Arn FilterCriteria: Filters: - - Pattern: '{"name": "value"}' + - Pattern: '{"name": "value"}' MSKEvent: Type: MSK Properties: StartingPosition: LATEST Stream: arn:aws:kafka:us-west-2:012345678901:cluster/mycluster/6cc0432b-8618-4f44-bccc-e1fbd8fb7c4d-2 Topics: - - "MyDummyTestTopic" + - MyDummyTestTopic FilterCriteria: Filters: - - Pattern: '{"name": "value"}' + - Pattern: '{"name": "value"}' MyKafkaEvent: Type: SelfManagedKafka Properties: KafkaBootstrapServers: - - "abc.xyz.com:9092" + - abc.xyz.com:9092 Topics: - - "Topic1" + - Topic1 SourceAccessConfigurations: - - Type: SASL_SCRAM_512_AUTH - URI: arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c - - Type: VPC_SUBNET - URI: subnet:subnet-12345 - - Type: VPC_SECURITY_GROUP - URI: security_group:sg-67890 + - Type: SASL_SCRAM_512_AUTH + URI: arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c + - Type: VPC_SUBNET + URI: subnet:subnet-12345 + - Type: VPC_SECURITY_GROUP + URI: security_group:sg-67890 FilterCriteria: Filters: - - Pattern: '{"name": "value"}' + - Pattern: '{"name": "value"}' MyMQQueue: Type: MQ Properties: Broker: arn:aws:mq:us-east-2:123456789012:broker:MyBroker:b-1234a5b6-78cd-901e-2fgh-3i45j6k178l9 Queues: - - "Queue1" + - Queue1 SourceAccessConfigurations: - - Type: BASIC_AUTH - URI: arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c + - Type: BASIC_AUTH + URI: arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c SecretsManagerKmsKeyId: 1abc23d4-567f-8ab9-cde0-1fab234c5d67 FilterCriteria: Filters: - - Pattern: '{"name": "value"}' + - Pattern: '{"name": "value"}' KinesisStream: Type: AWS::Kinesis::Stream @@ -86,4 +83,4 @@ Resources: Type: AWS::DynamoDB::Table MySqsQueue: - Type: AWS::SQS::Queue \ No newline at end of file + Type: AWS::SQS::Queue diff --git a/tests/functional/commands/validate/lib/models/function_with_event_schedule_state.yaml b/tests/functional/commands/validate/lib/models/function_with_event_schedule_state.yaml index 17a13f6549..4c1562766d 100644 --- a/tests/functional/commands/validate/lib/models/function_with_event_schedule_state.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_event_schedule_state.yaml @@ -1,12 +1,16 @@ -Transform: "AWS::Serverless-2016-10-31" +%YAML 1.1 +--- +Transform: AWS::Serverless-2016-10-31 Parameters: ScheduleState: Type: String Default: Disabled + KMSKeyArn: + Type: String Resources: ScheduledFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO Handler: hello.handler @@ -15,21 +19,41 @@ Resources: Schedule1: Type: Schedule Properties: - Schedule: 'rate(1 minute)' + Schedule: rate(1 minute) Name: test-schedule Description: Test Schedule - State: "Enabled" + State: Enabled Schedule2: Type: Schedule Properties: - Schedule: 'rate(1 minute)' + Schedule: rate(1 minute) Name: test-schedule Description: Test Schedule State: !Sub "Enabled" Schedule3: Type: Schedule Properties: - Schedule: 'rate(1 minute)' + Schedule: rate(1 minute) Name: test-schedule Description: Test Schedule - State: !Ref ScheduleState \ No newline at end of file + State: !Ref ScheduleState + ScheduleV2: + Type: ScheduleV2 + Properties: + ScheduleExpression: rate(1 minute) + ScheduleV2MoreProperties: + Type: ScheduleV2 + Properties: + ScheduleExpression: rate(1 minute) + Name: test-scheduler + Description: Test Schedule + FlexibleTimeWindow: + Mode: FLEXIBLE + MaximumWindowInMinutes: 5 + State: !Ref ScheduleState + StartDate: '2014-10-02T15:01:23' + EndDate: '2015-10-02T15:01:23' + ScheduleExpressionTimezone: UTC + GroupName: group-name + KmsKeyArn: !Ref KMSKeyArn + PermissionsBoundary: arn:aws:1234:iam:boundary/CustomerCreatedPermissionsBoundaryForSchedule diff --git a/tests/functional/commands/validate/lib/models/function_with_event_source_mapping.yaml b/tests/functional/commands/validate/lib/models/function_with_event_source_mapping.yaml index 7a55afa02f..d04ec98243 100644 --- a/tests/functional/commands/validate/lib/models/function_with_event_source_mapping.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_event_source_mapping.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 @@ -22,8 +24,8 @@ Resources: } Runtime: nodejs12.x Policies: - - SQSSendMessagePolicy: - QueueName: !GetAtt MySqsQueue.QueueName + - SQSSendMessagePolicy: + QueueName: !GetAtt MySqsQueue.QueueName Events: Stream: Type: Kinesis @@ -54,7 +56,7 @@ Resources: StartingPosition: TRIM_HORIZON TumblingWindowInSeconds: 60 FunctionResponseTypes: - - ReportBatchItemFailures + - ReportBatchItemFailures DestinationConfig: OnFailure: Type: SQS @@ -89,11 +91,11 @@ Resources: Type: AWS::DynamoDB::Table Properties: AttributeDefinitions: - - AttributeName: id - AttributeType: S + - AttributeName: id + AttributeType: S KeySchema: - - AttributeName: id - KeyType: HASH + - AttributeName: id + KeyType: HASH ProvisionedThroughput: ReadCapacityUnits: 5 WriteCapacityUnits: 5 @@ -103,4 +105,4 @@ Resources: MySqsQueue: Type: AWS::SQS::Queue MySnsTopic: - Type: AWS::SNS::Topic \ No newline at end of file + Type: AWS::SNS::Topic diff --git a/tests/functional/commands/validate/lib/models/function_with_file_system_config.yaml b/tests/functional/commands/validate/lib/models/function_with_file_system_config.yaml index 46864d092f..a7e4d49a2c 100644 --- a/tests/functional/commands/validate/lib/models/function_with_file_system_config.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_file_system_config.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Description: SAM + Lambda + EFS Parameters: @@ -49,5 +51,5 @@ Resources: SecurityGroupIds: !Ref SecurityGroupIds SubnetIds: !Ref VpcSubnetIds FileSystemConfigs: - - Arn: !GetAtt AccessPoint.Arn - LocalMountPath: /mnt/EFS + - Arn: !GetAtt AccessPoint.Arn + LocalMountPath: /mnt/EFS diff --git a/tests/functional/commands/validate/lib/models/function_with_function_url_config.yaml b/tests/functional/commands/validate/lib/models/function_with_function_url_config.yaml index 0932924137..68345913ab 100644 --- a/tests/functional/commands/validate/lib/models/function_with_function_url_config.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_function_url_config.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Parameters: {} Resources: @@ -13,17 +15,16 @@ Resources: FunctionUrlConfig: AuthType: NONE Cors: - AllowOrigins: - - "https://example.com" - - "example1.com" - - "example2.com" - - "example2.com" - AllowMethods: - - "GET" - AllowCredentials: true - AllowHeaders: - - "x-Custom-Header" - ExposeHeaders: - - "x-amzn-header" - MaxAge: 10 - + AllowOrigins: + - https://example.com + - example1.com + - example2.com + - example2.com + AllowMethods: + - GET + AllowCredentials: true + AllowHeaders: + - x-Custom-Header + ExposeHeaders: + - x-amzn-header + MaxAge: 10 diff --git a/tests/functional/commands/validate/lib/models/function_with_function_url_config_and_autopublishalias.yaml b/tests/functional/commands/validate/lib/models/function_with_function_url_config_and_autopublishalias.yaml index ab43785e79..04a64f4df6 100644 --- a/tests/functional/commands/validate/lib/models/function_with_function_url_config_and_autopublishalias.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_function_url_config_and_autopublishalias.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Parameters: {} Resources: @@ -14,16 +16,16 @@ Resources: FunctionUrlConfig: AuthType: NONE Cors: - AllowOrigins: - - "https://example.com" - - "example1.com" - - "example2.com" - - "example2.com" - AllowMethods: - - "GET" - AllowCredentials: true - AllowHeaders: - - "x-Custom-Header" - ExposeHeaders: - - "x-amzn-header" - MaxAge: 10 + AllowOrigins: + - https://example.com + - example1.com + - example2.com + - example2.com + AllowMethods: + - GET + AllowCredentials: true + AllowHeaders: + - x-Custom-Header + ExposeHeaders: + - x-amzn-header + MaxAge: 10 diff --git a/tests/functional/commands/validate/lib/models/function_with_function_url_config_conditions.yaml b/tests/functional/commands/validate/lib/models/function_with_function_url_config_conditions.yaml index 40c2bce958..9af4a7122b 100644 --- a/tests/functional/commands/validate/lib/models/function_with_function_url_config_conditions.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_function_url_config_conditions.yaml @@ -1,9 +1,11 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Conditions: MyCondition: Fn::Equals: - - true - - true + - true + - true Parameters: {} Resources: MyFunction: @@ -19,17 +21,16 @@ Resources: FunctionUrlConfig: AuthType: NONE Cors: - AllowOrigins: - - "https://example.com" - - "example1.com" - - "example2.com" - - "example2.com" - AllowMethods: - - "GET" - AllowCredentials: true - AllowHeaders: - - "x-Custom-Header" - ExposeHeaders: - - "x-amzn-header" - MaxAge: 10 - + AllowOrigins: + - https://example.com + - example1.com + - example2.com + - example2.com + AllowMethods: + - GET + AllowCredentials: true + AllowHeaders: + - x-Custom-Header + ExposeHeaders: + - x-amzn-header + MaxAge: 10 diff --git a/tests/functional/commands/validate/lib/models/function_with_function_url_config_with_iam_authorization_type.yaml b/tests/functional/commands/validate/lib/models/function_with_function_url_config_with_iam_authorization_type.yaml index c20364da7b..1b5f983658 100644 --- a/tests/functional/commands/validate/lib/models/function_with_function_url_config_with_iam_authorization_type.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_function_url_config_with_iam_authorization_type.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Parameters: {} Resources: @@ -13,17 +15,16 @@ Resources: FunctionUrlConfig: AuthType: AWS_IAM Cors: - AllowOrigins: - - "https://example.com" - - "example1.com" - - "example2.com" - - "example2.com" - AllowMethods: - - "GET" - AllowCredentials: true - AllowHeaders: - - "x-Custom-Header" - ExposeHeaders: - - "x-amzn-header" - MaxAge: 10 - + AllowOrigins: + - https://example.com + - example1.com + - example2.com + - example2.com + AllowMethods: + - GET + AllowCredentials: true + AllowHeaders: + - x-Custom-Header + ExposeHeaders: + - x-amzn-header + MaxAge: 10 diff --git a/tests/functional/commands/validate/lib/models/function_with_function_url_config_with_intrinsics.yaml b/tests/functional/commands/validate/lib/models/function_with_function_url_config_with_intrinsics.yaml index 165f9247a6..314f883ad4 100644 --- a/tests/functional/commands/validate/lib/models/function_with_function_url_config_with_intrinsics.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_function_url_config_with_intrinsics.yaml @@ -1,16 +1,18 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' -Parameters: +Parameters: AuthorizationTypeRef: - Type: String - Default: NONE + Type: String + Default: NONE AllowOriginsRef: - Type: CommaDelimitedList - Default: "https://example.com" + Type: CommaDelimitedList + Default: https://example.com AllowMethodsRef: - Type: CommaDelimitedList - Default: "GET" + Type: CommaDelimitedList + Default: GET Resources: MyFunction: @@ -25,7 +27,5 @@ Resources: FunctionUrlConfig: AuthType: !Ref AuthorizationTypeRef Cors: - AllowOrigins: !Ref AllowOriginsRef - AllowMethods: !Ref AllowMethodsRef - - + AllowOrigins: !Ref AllowOriginsRef + AllowMethods: !Ref AllowMethodsRef diff --git a/tests/functional/commands/validate/lib/models/function_with_function_url_config_without_cors_config.yaml b/tests/functional/commands/validate/lib/models/function_with_function_url_config_without_cors_config.yaml index a9cc9f51e6..09f1d50a2e 100644 --- a/tests/functional/commands/validate/lib/models/function_with_function_url_config_without_cors_config.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_function_url_config_without_cors_config.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Parameters: {} Resources: @@ -12,4 +14,3 @@ Resources: Timeout: 3 FunctionUrlConfig: AuthType: NONE - diff --git a/tests/functional/commands/validate/lib/models/function_with_global_layers.yaml b/tests/functional/commands/validate/lib/models/function_with_global_layers.yaml index 2b4d6eb32f..bc02edd911 100644 --- a/tests/functional/commands/validate/lib/models/function_with_global_layers.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_global_layers.yaml @@ -1,19 +1,20 @@ +%YAML 1.1 +--- Globals: Function: Layers: - - arn:aws:lambda:us-east-1:123456789101:layer:layer1:1 - - arn:aws:lambda:us-east-1:123456789101:layer:layer2:1 + - arn:aws:lambda:us-east-1:123456789101:layer:layer1:1 + - arn:aws:lambda:us-east-1:123456789101:layer:layer2:1 # Note: there is a limit to the number of layers that a function can reference. Resources: ManyLayersFunc: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python3.6 Layers: - - arn:aws:lambda:us-east-1:123456789101:layer:layer3:1 - - arn:aws:lambda:us-east-1:123456789101:layer:layer4:1 - - arn:aws:lambda:us-east-1:123456789101:layer:layer5:1 - + - arn:aws:lambda:us-east-1:123456789101:layer:layer3:1 + - arn:aws:lambda:us-east-1:123456789101:layer:layer4:1 + - arn:aws:lambda:us-east-1:123456789101:layer:layer5:1 diff --git a/tests/functional/commands/validate/lib/models/function_with_intrinsic_architecture.yaml b/tests/functional/commands/validate/lib/models/function_with_intrinsic_architecture.yaml index fff593ab9f..975fcfb929 100644 --- a/tests/functional/commands/validate/lib/models/function_with_intrinsic_architecture.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_intrinsic_architecture.yaml @@ -1,16 +1,18 @@ +%YAML 1.1 +--- Parameters: ArchitectureRef: Type: String - Default: 'arm64' -Resources: + Default: arm64 +Resources: FunctionWithArchitecturesIntrinsic: Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Description: Created by SAM Handler: index.handler - Architectures: + Architectures: Ref: ArchitectureRef MemorySize: 1024 Runtime: nodejs12.x - Timeout: 3 \ No newline at end of file + Timeout: 3 diff --git a/tests/functional/commands/validate/lib/models/function_with_kmskeyarn.yaml b/tests/functional/commands/validate/lib/models/function_with_kmskeyarn.yaml index 4679b19a06..aab86a67a1 100644 --- a/tests/functional/commands/validate/lib/models/function_with_kmskeyarn.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_kmskeyarn.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: FunctionWithKeyArn: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -8,27 +10,26 @@ Resources: KmsKeyArn: thisIsaKey FunctionWithReferenceToKeyArn: - Type: 'AWS::Serverless::Function' - Properties: - CodeUri: s3://sam-demo-bucket/hello.zip - Handler: hello.handler - Runtime: python2.7 - KmsKeyArn: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip + Handler: hello.handler + Runtime: python2.7 + KmsKeyArn: Ref: myKey myKey: - Type: "AWS::KMS::Key" - Properties: - Description: "A sample key" - KeyPolicy: - Version: "2012-10-17" - Id: "key-default-1" - Statement: - - - Sid: "Allow administration of the key" - Effect: "Allow" - Principal: - AWS: "arn:aws:iam::123456789012:user/Alice" - Action: - - "kms:Create*" - Resource: "*" + Type: AWS::KMS::Key + Properties: + Description: A sample key + KeyPolicy: + Version: '2012-10-17' + Id: key-default-1 + Statement: + - Sid: Allow administration of the key + Effect: Allow + Principal: + AWS: arn:aws:iam::123456789012:user/Alice + Action: + - kms:Create* + Resource: '*' diff --git a/tests/functional/commands/validate/lib/models/function_with_layers.yaml b/tests/functional/commands/validate/lib/models/function_with_layers.yaml index 1e34324d02..d5a165cb60 100644 --- a/tests/functional/commands/validate/lib/models/function_with_layers.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_layers.yaml @@ -1,42 +1,44 @@ +%YAML 1.1 +--- Resources: MinimalLayerFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 Layers: - - arn:aws:lambda:us-east-1:123456789101:layer:CorpXLayer:1 + - arn:aws:lambda:us-east-1:123456789101:layer:CorpXLayer:1 FunctionNoLayerVersion: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 Layers: - - arn:aws:lambda:us-east-1:123456789101:layer:CorpXLayer:1 + - arn:aws:lambda:us-east-1:123456789101:layer:CorpXLayer:1 FunctionLayerWithSubIntrinsic: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 Layers: - - !Sub arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:layer:CorpXLayer:1 - - Fn::Sub: arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:layer:CorpYLayer:1 + - !Sub arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:layer:CorpXLayer:1 + - Fn::Sub: arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:layer:CorpYLayer:1 FunctionReferencesLayer: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 Layers: - - !Ref MyLayer + - !Ref MyLayer MyLayer: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: ContentUri: s3://sam-demo-bucket/layer.zip diff --git a/tests/functional/commands/validate/lib/models/function_with_many_layers.yaml b/tests/functional/commands/validate/lib/models/function_with_many_layers.yaml index 78ba2bc4ab..a7ae76b153 100644 --- a/tests/functional/commands/validate/lib/models/function_with_many_layers.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_many_layers.yaml @@ -1,18 +1,20 @@ +%YAML 1.1 +--- Resources: ManyLayersFunc: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 Layers: - - arn:aws:lambda:us-east-1:123456789101:layer:z:1 - - !Sub arn:aws:lambda:${AWS::Region}:123456789101:layer:a:1 - - arn:aws:lambda:us-east-1:123456789101:layer:d12345678:1 - - !Sub arn:${AWS::Partition}:lambda:${AWS::Region}:123456789101:layer:c:1 - - !Ref MyLayer + - arn:aws:lambda:us-east-1:123456789101:layer:z:1 + - !Sub arn:aws:lambda:${AWS::Region}:123456789101:layer:a:1 + - arn:aws:lambda:us-east-1:123456789101:layer:d12345678:1 + - !Sub arn:${AWS::Partition}:lambda:${AWS::Region}:123456789101:layer:c:1 + - !Ref MyLayer MyLayer: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: ContentUri: s3://sam-demo-bucket/layer.zip diff --git a/tests/functional/commands/validate/lib/models/function_with_mq_virtual_host.yaml b/tests/functional/commands/validate/lib/models/function_with_mq_virtual_host.yaml index b5d2c62085..bf9d322cee 100644 --- a/tests/functional/commands/validate/lib/models/function_with_mq_virtual_host.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_mq_virtual_host.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MQFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/queues.zip Handler: queue.mq_handler @@ -11,9 +13,9 @@ Resources: Properties: Broker: arn:aws:mq:us-east-2:123456789012:broker:MyBroker:b-1234a5b6-78cd-901e-2fgh-3i45j6k178l9 Queues: - - "Queue1" + - Queue1 SourceAccessConfigurations: - - Type: BASIC_AUTH - URI: arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c - - Type: VIRTUAL_HOST - URI: vhost_name \ No newline at end of file + - Type: BASIC_AUTH + URI: arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c + - Type: VIRTUAL_HOST + URI: vhost_name diff --git a/tests/functional/commands/validate/lib/models/function_with_msk.yaml b/tests/functional/commands/validate/lib/models/function_with_msk.yaml index 6ac5e8ddc8..cb5f2d631f 100644 --- a/tests/functional/commands/validate/lib/models/function_with_msk.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_msk.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Parameters: {} @@ -15,6 +17,5 @@ Resources: StartingPosition: LATEST Stream: !Sub arn:aws:kafka:${AWS::Region}:012345678901:cluster/mycluster/6cc0432b-8618-4f44-bccc-e1fbd8fb7c4d-2 Topics: - - "MyDummyTestTopic" + - MyDummyTestTopic ConsumerGroupId: consumergroup1 - diff --git a/tests/functional/commands/validate/lib/models/function_with_msk_with_intrinsics.yaml b/tests/functional/commands/validate/lib/models/function_with_msk_with_intrinsics.yaml index de380a72c2..a77ff9044a 100644 --- a/tests/functional/commands/validate/lib/models/function_with_msk_with_intrinsics.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_msk_with_intrinsics.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Parameters: StartingPositionValue: @@ -32,4 +34,3 @@ Resources: Stream: !Ref StreamValue Topics: !Ref TopicsValue ConsumerGroupId: !Ref ConsumerGroupValue - diff --git a/tests/functional/commands/validate/lib/models/function_with_null_events.yaml b/tests/functional/commands/validate/lib/models/function_with_null_events.yaml index 3a49fa6ffb..cdf01e02c5 100644 --- a/tests/functional/commands/validate/lib/models/function_with_null_events.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_null_events.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: FunctionWithNullEvents: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/queues.zip Handler: handlers.handler diff --git a/tests/functional/commands/validate/lib/models/function_with_permissions_boundary.yaml b/tests/functional/commands/validate/lib/models/function_with_permissions_boundary.yaml index 5cad58b7f9..e03766c4eb 100644 --- a/tests/functional/commands/validate/lib/models/function_with_permissions_boundary.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_permissions_boundary.yaml @@ -1,9 +1,10 @@ +%YAML 1.1 +--- Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 PermissionsBoundary: arn:aws:1234:iam:boundary/CustomerCreatedPermissionsBoundary - diff --git a/tests/functional/commands/validate/lib/models/function_with_policy_templates.yaml b/tests/functional/commands/validate/lib/models/function_with_policy_templates.yaml index 34fd86683f..c3d16421aa 100644 --- a/tests/functional/commands/validate/lib/models/function_with_policy_templates.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_policy_templates.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: FunctionNameParam: Type: String @@ -5,7 +7,7 @@ Parameters: Resources: OnePolicyTemplate: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -13,43 +15,43 @@ Resources: Policies: SQSPollerPolicy: QueueName: - Fn::Sub: ["Some${value}", {"value": "KeyId"}] + Fn::Sub: ['Some${value}', value: KeyId] # Extra parameters will be skipped, and not appear in output ExtraParam1: Value1 ExtraParam2: Value2 MultiplePolicyTemplates: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 Policies: - - SQSPollerPolicy: - QueueName: "Somekey" - - LambdaInvokePolicy: - FunctionName: "Some function" + - SQSPollerPolicy: + QueueName: Somekey + - LambdaInvokePolicy: + FunctionName: Some function AllCombinations: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 Policies: # Inline statement - - Statement: - - Action: [ 'dynamodb:*' ] - Effect: Allow - Resource: '*' + - Statement: + - Action: [dynamodb:*] + Effect: Allow + Resource: '*' # Regular managed policy - - AmazonDynamoDBFullAccess + - AmazonDynamoDBFullAccess - - LambdaInvokePolicy: - FunctionName: + - LambdaInvokePolicy: + FunctionName: # Refer to something - Ref: FunctionNameParam + Ref: FunctionNameParam # Regular managed policy - - AWSLambdaRole + - AWSLambdaRole diff --git a/tests/functional/commands/validate/lib/models/function_with_request_parameters.yaml b/tests/functional/commands/validate/lib/models/function_with_request_parameters.yaml index 2875457c5a..1bd5a5aa7b 100644 --- a/tests/functional/commands/validate/lib/models/function_with_request_parameters.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_request_parameters.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: Api: @@ -19,9 +21,9 @@ Resources: Path: / Method: get RequestParameters: - - method.request.header.Authorization: - Required: true - Caching: true + - method.request.header.Authorization: + Required: true + Caching: true NoApiParameterFunction: Type: AWS::Serverless::Function @@ -36,6 +38,6 @@ Resources: Path: / Method: get RequestParameters: - - method.request.querystring.type - - method.request.path.id - - method.request.querystring.full.type + - method.request.querystring.type + - method.request.path.id + - method.request.querystring.full.type diff --git a/tests/functional/commands/validate/lib/models/function_with_resource_refs.yaml b/tests/functional/commands/validate/lib/models/function_with_resource_refs.yaml index 02732661c6..88e417d1ed 100644 --- a/tests/functional/commands/validate/lib/models/function_with_resource_refs.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_resource_refs.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- # Test to verify that resource references available on the Function are properly resolved # Currently supported references are: # - Alias @@ -6,7 +8,7 @@ Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -14,7 +16,7 @@ Resources: AutoPublishAlias: live FunctionWithoutAlias: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -24,7 +26,7 @@ Resources: Type: AWS::S3::Bucket Properties: Name: - Fn::GetAtt: ["MinimalFunction.Alias", "Name"] + Fn::GetAtt: [MinimalFunction.Alias, Name] Outputs: AliasArn: @@ -39,13 +41,14 @@ Outputs: AliasInSub: Value: - Fn::Sub: ["Hello ${MinimalFunction.Alias} ${MinimalFunction.Alias.Name} ${SomeValue}", {"SomeValue": "World"}] + Fn::Sub: ['Hello ${MinimalFunction.Alias} ${MinimalFunction.Alias.Name} ${SomeValue}', + SomeValue: World] VersionArn: Value: !Ref MinimalFunction.Version VersionNumber: Value: - Fn::GetAtt: ["MinimalFunction.Version", "Version"] + Fn::GetAtt: [MinimalFunction.Version, Version] UnResolvedVersion: Value: diff --git a/tests/functional/commands/validate/lib/models/function_with_self_managed_kafka.yaml b/tests/functional/commands/validate/lib/models/function_with_self_managed_kafka.yaml index ef4b7d5d4a..c3050737b1 100644 --- a/tests/functional/commands/validate/lib/models/function_with_self_managed_kafka.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_self_managed_kafka.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Parameters: {} Resources: KafkaFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/kafka.zip Handler: index.kafka_handler @@ -12,16 +14,15 @@ Resources: Type: SelfManagedKafka Properties: KafkaBootstrapServers: - - "abc.xyz.com:9092" - - "123.45.67.89:9096" + - abc.xyz.com:9092 + - 123.45.67.89:9096 Topics: - - "Topic1" + - Topic1 SourceAccessConfigurations: - - Type: SASL_SCRAM_512_AUTH - URI: arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c - - Type: VPC_SUBNET - URI: subnet:subnet-12345 - - Type: VPC_SECURITY_GROUP - URI: security_group:sg-67890 + - Type: SASL_SCRAM_512_AUTH + URI: arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c + - Type: VPC_SUBNET + URI: subnet:subnet-12345 + - Type: VPC_SECURITY_GROUP + URI: security_group:sg-67890 ConsumerGroupId: consumergroup1 - diff --git a/tests/functional/commands/validate/lib/models/function_with_signing_profile.yaml b/tests/functional/commands/validate/lib/models/function_with_signing_profile.yaml index 09a0323670..48b9f06541 100644 --- a/tests/functional/commands/validate/lib/models/function_with_signing_profile.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_signing_profile.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: FunctionWithSigningProfile: @@ -11,14 +13,14 @@ Resources: MySignedFunctionCodeSigningConfig: Type: AWS::Lambda::CodeSigningConfig Properties: - Description: "Code Signing for MySignedLambdaFunction" + Description: Code Signing for MySignedLambdaFunction AllowedPublishers: SigningProfileVersionArns: - - !GetAtt SigningProfile.ProfileVersionArn + - !GetAtt SigningProfile.ProfileVersionArn CodeSigningPolicies: - UntrustedArtifactOnDeployment: "Enforce" + UntrustedArtifactOnDeployment: Enforce SigningProfile: Type: AWS::Signer::SigningProfile Properties: - PlatformId: AWSLambda-SHA384-ECDSA \ No newline at end of file + PlatformId: AWSLambda-SHA384-ECDSA diff --git a/tests/functional/commands/validate/lib/models/function_with_sns_event_source_all_parameters.yaml b/tests/functional/commands/validate/lib/models/function_with_sns_event_source_all_parameters.yaml index 65711e7330..7e57bf64ae 100644 --- a/tests/functional/commands/validate/lib/models/function_with_sns_event_source_all_parameters.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_sns_event_source_all_parameters.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyAwesomeFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -23,7 +25,5 @@ Resources: - baseball price_usd: - numeric: - - ">=" + - '>=' - 100 - - diff --git a/tests/functional/commands/validate/lib/models/function_with_vpc_permission_for_self_managed_kafka.yaml b/tests/functional/commands/validate/lib/models/function_with_vpc_permission_for_self_managed_kafka.yaml index fe231e32c6..555f0b2389 100644 --- a/tests/functional/commands/validate/lib/models/function_with_vpc_permission_for_self_managed_kafka.yaml +++ b/tests/functional/commands/validate/lib/models/function_with_vpc_permission_for_self_managed_kafka.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Parameters: {} Resources: KafkaFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/kafka.zip Handler: index.kafka_handler @@ -12,13 +14,12 @@ Resources: Type: SelfManagedKafka Properties: KafkaBootstrapServers: - - "abc.xyz.com:9092" - - "123.45.67.89:9096" + - abc.xyz.com:9092 + - 123.45.67.89:9096 Topics: - - "Topic1" + - Topic1 SourceAccessConfigurations: - - Type: VPC_SUBNET - URI: subnet:subnet-12345 - - Type: VPC_SECURITY_GROUP - URI: security_group:sg-67890 - + - Type: VPC_SUBNET + URI: subnet:subnet-12345 + - Type: VPC_SECURITY_GROUP + URI: security_group:sg-67890 diff --git a/tests/functional/commands/validate/lib/models/global_handle_path_level_parameter.yaml b/tests/functional/commands/validate/lib/models/global_handle_path_level_parameter.yaml index 0b8e642f14..b8386b4139 100644 --- a/tests/functional/commands/validate/lib/models/global_handle_path_level_parameter.yaml +++ b/tests/functional/commands/validate/lib/models/global_handle_path_level_parameter.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- Globals: Api: - Name: "some api" - CacheClusterEnabled: True - CacheClusterSize: "1.6" + Name: some api + CacheClusterEnabled: true + CacheClusterSize: '1.6' Auth: DefaultAuthorizer: MyCognitoAuth Authorizers: @@ -35,13 +37,13 @@ Resources: version: '1.0' title: !Ref AWS::StackName paths: - "/": + /: parameters: - - name: domain - in: path - description: Application domain - type: string - required: true + - name: domain + in: path + description: Application domain + type: string + required: true get: x-amazon-apigateway-integration: httpMethod: POST @@ -57,8 +59,8 @@ Resources: PasswordPolicy: MinimumLength: 8 UsernameAttributes: - - email + - email Schema: - - AttributeDataType: String - Name: email - Required: false \ No newline at end of file + - AttributeDataType: String + Name: email + Required: false diff --git a/tests/functional/commands/validate/lib/models/globals_for_api.yaml b/tests/functional/commands/validate/lib/models/globals_for_api.yaml index e68eddfcf2..3d3aed422d 100644 --- a/tests/functional/commands/validate/lib/models/globals_for_api.yaml +++ b/tests/functional/commands/validate/lib/models/globals_for_api.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- Globals: Api: - Name: "some api" - CacheClusterEnabled: True - CacheClusterSize: "1.6" + Name: some api + CacheClusterEnabled: true + CacheClusterSize: '1.6' Auth: DefaultAuthorizer: MyCognitoAuth Authorizers: @@ -36,7 +38,7 @@ Resources: version: '1.0' title: !Ref AWS::StackName paths: - "/": + /: get: x-amazon-apigateway-integration: httpMethod: POST @@ -52,8 +54,8 @@ Resources: PasswordPolicy: MinimumLength: 8 UsernameAttributes: - - email + - email Schema: - - AttributeDataType: String - Name: email - Required: false \ No newline at end of file + - AttributeDataType: String + Name: email + Required: false diff --git a/tests/functional/commands/validate/lib/models/globals_for_function.yaml b/tests/functional/commands/validate/lib/models/globals_for_function.yaml index 2fc6da8d3b..8f5702ce45 100644 --- a/tests/functional/commands/validate/lib/models/globals_for_function.yaml +++ b/tests/functional/commands/validate/lib/models/globals_for_function.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: Function: CodeUri: s3://global-bucket/global.zip @@ -7,9 +9,9 @@ Globals: Timeout: 30 VpcConfig: SecurityGroupIds: - - sg-edcd9784 + - sg-edcd9784 SubnetIds: - - sub-id-2 + - sub-id-2 Environment: Variables: Var1: value1 @@ -20,19 +22,19 @@ Globals: AutoPublishAlias: live PermissionsBoundary: arn:aws:1234:iam:boundary/CustomerCreatedPermissionsBoundary Layers: - - !Sub arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:layer:MyLayer:1 + - !Sub arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:layer:MyLayer:1 ReservedConcurrentExecutions: 50 Architectures: - - x86_64 - EphemeralStorage: + - x86_64 + EphemeralStorage: Size: 1024 Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function FunctionWithOverrides: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: index.handler @@ -40,8 +42,8 @@ Resources: MemorySize: 512 Timeout: 100 VpcConfig: - SecurityGroupIds: - - sg-123 + SecurityGroupIds: + - sg-123 Environment: Variables: Var3: value3 @@ -51,6 +53,5 @@ Resources: AutoPublishAlias: prod PermissionsBoundary: arn:aws:1234:iam:boundary/OverridePermissionsBoundary Layers: - - !Sub arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:layer:MyLayer2:2 + - !Sub arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:layer:MyLayer2:2 ReservedConcurrentExecutions: 100 - diff --git a/tests/functional/commands/validate/lib/models/globals_for_simpletable.yaml b/tests/functional/commands/validate/lib/models/globals_for_simpletable.yaml index 6a03a75ed7..fa1c90da4a 100644 --- a/tests/functional/commands/validate/lib/models/globals_for_simpletable.yaml +++ b/tests/functional/commands/validate/lib/models/globals_for_simpletable.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: SimpleTable: SSESpecification: @@ -5,4 +7,4 @@ Globals: Resources: MinimalTable: - Type: AWS::Serverless::SimpleTable \ No newline at end of file + Type: AWS::Serverless::SimpleTable diff --git a/tests/functional/commands/validate/lib/models/http_api_custom_iam_auth.yaml b/tests/functional/commands/validate/lib/models/http_api_custom_iam_auth.yaml index 35220d0237..08e78d8517 100644 --- a/tests/functional/commands/validate/lib/models/http_api_custom_iam_auth.yaml +++ b/tests/functional/commands/validate/lib/models/http_api_custom_iam_auth.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- # This test-case tests what happens when an AWS_IAM authorizer is defined on an HttpApi but not enabled anywhere else. # While the defined authorizer isn't really a true Iam authorizer (it's just a poorly-named OAuth authorizer) this shouldn't cause an error. Resources: @@ -34,11 +36,11 @@ Resources: Authorizers: AWS_IAM: AuthorizationScopes: - - scope + - scope IdentitySource: $request.header.Authorization JwtConfiguration: audience: - - audience1 - - audience2 - issuer: "https://www.example.com/v1/connect/oidc" + - audience1 + - audience2 + issuer: https://www.example.com/v1/connect/oidc DefaultAuthorizer: AWS_IAM diff --git a/tests/functional/commands/validate/lib/models/http_api_def_uri.yaml b/tests/functional/commands/validate/lib/models/http_api_def_uri.yaml index 0182af3940..5e3d69613d 100644 --- a/tests/functional/commands/validate/lib/models/http_api_def_uri.yaml +++ b/tests/functional/commands/validate/lib/models/http_api_def_uri.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: HttpApi: DefaultRouteSettings: @@ -8,7 +10,7 @@ Resources: Type: AWS::Serverless::HttpApi Properties: DefinitionUri: s3://bucket/key - StageName: !Join ["", ["Stage", "Name"]] + StageName: !Join ['', [Stage, Name]] DefaultRouteSettings: ThrottlingBurstLimit: 50 @@ -34,4 +36,4 @@ Resources: Api2: Type: HttpApi Properties: - ApiId: !Ref MyApi2 \ No newline at end of file + ApiId: !Ref MyApi2 diff --git a/tests/functional/commands/validate/lib/models/http_api_description.yaml b/tests/functional/commands/validate/lib/models/http_api_description.yaml index 268584d89d..a5677e1732 100644 --- a/tests/functional/commands/validate/lib/models/http_api_description.yaml +++ b/tests/functional/commands/validate/lib/models/http_api_description.yaml @@ -1,11 +1,13 @@ +%YAML 1.1 +--- Resources: HttpApi: Type: AWS::Serverless::HttpApi Properties: DefinitionBody: - openapi: "3.0.1" + openapi: 3.0.1 paths: - "/foo": {} + /foo: {} Description: my description Function: diff --git a/tests/functional/commands/validate/lib/models/http_api_existing_openapi.yaml b/tests/functional/commands/validate/lib/models/http_api_existing_openapi.yaml index 891d9199e9..c9876ef27b 100644 --- a/tests/functional/commands/validate/lib/models/http_api_existing_openapi.yaml +++ b/tests/functional/commands/validate/lib/models/http_api_existing_openapi.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: Timeout: Default: 15000 @@ -7,11 +9,11 @@ Globals: HttpApi: CorsConfiguration: AllowHeaders: - - x-apigateway-header + - x-apigateway-header AllowMethods: - - GET + - GET AllowOrigins: - - https://global.com + - https://global.com MaxAge: 6000 Resources: @@ -47,7 +49,7 @@ Resources: Properties: CorsConfiguration: AllowOrigins: - - "https://local.com" + - https://local.com DefinitionBody: info: version: '1.0' @@ -55,12 +57,12 @@ Resources: Ref: AWS::StackName x-amazon-apigateway-cors: allowOrigins: - - "https://www.overriden.com" + - https://www.overriden.com allowMethods: - - "POST" + - POST maxAge: 3600 paths: - "/basic": + /basic: post: x-amazon-apigateway-integration: httpMethod: POST @@ -72,14 +74,13 @@ Resources: - OpenIdAuth: - scope3 responses: {} - "/get/{something}/with/{params}": + /get/{something}/with/{params}: get: parameters: - - - name: something - in: path + - name: something + in: path responses: {} - "/integration": + /integration: post: x-amazon-apigateway-integration: httpMethod: POST @@ -92,7 +93,7 @@ Resources: - scope1 - scope2 responses: {} - "$default": + $default: x-amazon-apigateway-any-method: isDefaultRoute: true security: @@ -100,7 +101,7 @@ Resources: - scope1 - scope2 responses: {} - "/oauth2": + /oauth2: post: x-amazon-apigateway-integration: httpMethod: POST @@ -118,7 +119,7 @@ Resources: oauth2Auth: type: oauth2 x-amazon-apigateway-authorizer: - identitySource: "$request.querystring.param" + identitySource: $request.querystring.param type: jwt jwtConfiguration: audience: @@ -127,7 +128,7 @@ Resources: OpenIdAuth: type: openIdConnect x-amazon-apigateway-authorizer: - identitySource: "$request.querystring.param" + identitySource: $request.querystring.param type: jwt jwtConfiguration: audience: diff --git a/tests/functional/commands/validate/lib/models/http_api_existing_openapi_conditions.yaml b/tests/functional/commands/validate/lib/models/http_api_existing_openapi_conditions.yaml index 6b9c91c5f2..23907d9c9b 100644 --- a/tests/functional/commands/validate/lib/models/http_api_existing_openapi_conditions.yaml +++ b/tests/functional/commands/validate/lib/models/http_api_existing_openapi_conditions.yaml @@ -1,10 +1,12 @@ +%YAML 1.1 +--- Conditions: condition: Fn::Equals: - - true - - true + - true + - true Resources: - HttpApiFunction: + HttpApiFunction: Condition: condition Type: AWS::Serverless::Function Properties: @@ -15,7 +17,7 @@ Resources: Basic: # integration exists Type: HttpApi Properties: - PayloadFormatVersion: "2.0" + PayloadFormatVersion: '2.0' Path: /basic Method: post ApiId: !Ref MyApi @@ -27,8 +29,8 @@ Resources: ApiId: !Ref MyApi Auth: Authorizer: OAuth2 - AuthorizationScopes: - - basic + AuthorizationScopes: + - basic SimpleCase: # path exists, integration doesn't Type: HttpApi Properties: @@ -43,12 +45,12 @@ Resources: Authorizers: OAuth2: AuthorizationScopes: - - scope4 + - scope4 JwtConfiguration: - issuer: "https://www.example.com/v1/connect/oidc" + issuer: https://www.example.com/v1/connect/oidc audience: - - MyApi - IdentitySource: "$request.querystring.param" + - MyApi + IdentitySource: $request.querystring.param DefaultAuthorizer: OAuth2 DefinitionBody: info: @@ -56,7 +58,7 @@ Resources: title: Ref: AWS::StackName paths: - "/basic": + /basic: post: x-amazon-apigateway-integration: httpMethod: POST @@ -76,7 +78,7 @@ Resources: Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${DifferentFunction.Arn}/invocations payloadFormatVersion: '1.0' responses: {} - "/integration": + /integration: post: x-amazon-apigateway-integration: httpMethod: POST @@ -89,7 +91,7 @@ Resources: - scope1 - scope2 responses: {} - "$default": + $default: x-amazon-apigateway-any-method: isDefaultRoute: true security: @@ -97,7 +99,7 @@ Resources: - scope1 - scope2 responses: {} - "/oauth2": + /oauth2: post: x-amazon-apigateway-integration: httpMethod: POST @@ -111,14 +113,14 @@ Resources: responses: {} openapi: 3.0.1 tags: - - name: Tag1 - description: this tag exists, but doesn't have an amazon extension value + - name: Tag1 + description: this tag exists, but doesn't have an amazon extension value components: securitySchemes: oauth2Auth: type: oauth2 x-amazon-apigateway-authorizer: - identitySource: "$request.querystring.param" + identitySource: $request.querystring.param type: jwt jwtConfiguration: audience: @@ -127,7 +129,7 @@ Resources: OpenIdAuth: type: openIdConnect x-amazon-apigateway-authorizer: - identitySource: "$request.querystring.param" + identitySource: $request.querystring.param type: jwt jwtConfiguration: audience: diff --git a/tests/functional/commands/validate/lib/models/http_api_explicit_stage.yaml b/tests/functional/commands/validate/lib/models/http_api_explicit_stage.yaml index 576ab3a6a7..dc7834d3f8 100644 --- a/tests/functional/commands/validate/lib/models/http_api_explicit_stage.yaml +++ b/tests/functional/commands/validate/lib/models/http_api_explicit_stage.yaml @@ -1,7 +1,9 @@ +%YAML 1.1 +--- Parameters: CorsParam: Type: String - Default: True + Default: true PayloadFormatVersion: Default: '1.0' Type: String @@ -9,12 +11,12 @@ Parameters: Globals: HttpApi: RouteSettings: - "$default": - DataTraceEnabled: True + $default: + DataTraceEnabled: true ThrottlingBurstLimit: 100 FailOnWarnings: true Resources: - HttpApiFunction: + HttpApiFunction: Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/todo_list.zip @@ -37,10 +39,10 @@ Resources: StageVariables: VarName: VarValue RouteSettings: - "$default": + $default: ThrottlingBurstLimit: 200 ThrottlingRateLimit: 0.7 AccessLogSettings: DestinationArn: arn:aws:logs:us-east-1:123456789012:log-group:LogGroupName Format: $context.requestId - CorsConfiguration: !Ref CorsParam \ No newline at end of file + CorsConfiguration: !Ref CorsParam diff --git a/tests/functional/commands/validate/lib/models/http_api_global_iam_auth_enabled.yaml b/tests/functional/commands/validate/lib/models/http_api_global_iam_auth_enabled.yaml index 84092f5eea..5b08e451a0 100644 --- a/tests/functional/commands/validate/lib/models/http_api_global_iam_auth_enabled.yaml +++ b/tests/functional/commands/validate/lib/models/http_api_global_iam_auth_enabled.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: HttpApi: Auth: diff --git a/tests/functional/commands/validate/lib/models/http_api_global_iam_auth_enabled_with_existing_conflicting_authorizer.yaml b/tests/functional/commands/validate/lib/models/http_api_global_iam_auth_enabled_with_existing_conflicting_authorizer.yaml index c0c05c7b4b..7ad47c88a1 100644 --- a/tests/functional/commands/validate/lib/models/http_api_global_iam_auth_enabled_with_existing_conflicting_authorizer.yaml +++ b/tests/functional/commands/validate/lib/models/http_api_global_iam_auth_enabled_with_existing_conflicting_authorizer.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- # This test-case tests what happens when an AWS_IAM authorizer is defined on an HttpApi and also enabled globally. # In this case the defined authorizer should NOT be overwritten. Globals: @@ -12,12 +14,12 @@ Resources: Authorizers: AWS_IAM: AuthorizationScopes: - - scope + - scope IdentitySource: $request.header.Authorization JwtConfiguration: audience: - - audience1 - - audience2 - issuer: "https://www.example.com/v1/connect/oidc" + - audience1 + - audience2 + issuer: https://www.example.com/v1/connect/oidc DefaultAuthorizer: AWS_IAM # EnableIamAuthorizer: true diff --git a/tests/functional/commands/validate/lib/models/http_api_lambda_auth.yaml b/tests/functional/commands/validate/lib/models/http_api_lambda_auth.yaml index 04bd02d603..cb94bd87de 100644 --- a/tests/functional/commands/validate/lib/models/http_api_lambda_auth.yaml +++ b/tests/functional/commands/validate/lib/models/http_api_lambda_auth.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HttpApiFunction: Type: AWS::Serverless::Function @@ -9,7 +11,7 @@ Resources: Basic: # integration exists Type: HttpApi Properties: - PayloadFormatVersion: "2.0" + PayloadFormatVersion: '2.0' Path: /basic Method: post ApiId: !Ref MyApi @@ -42,4 +44,4 @@ Resources: LambdaAuth: FunctionArn: !GetAtt MyAuthFn.Arn AuthorizerPayloadFormatVersion: 1.0 - DefaultAuthorizer: LambdaAuth \ No newline at end of file + DefaultAuthorizer: LambdaAuth diff --git a/tests/functional/commands/validate/lib/models/http_api_lambda_auth_full.yaml b/tests/functional/commands/validate/lib/models/http_api_lambda_auth_full.yaml index 5a5b976fa5..5bf3279ce3 100644 --- a/tests/functional/commands/validate/lib/models/http_api_lambda_auth_full.yaml +++ b/tests/functional/commands/validate/lib/models/http_api_lambda_auth_full.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HttpApiFunction: Type: AWS::Serverless::Function @@ -9,7 +11,7 @@ Resources: Basic: # integration exists Type: HttpApi Properties: - PayloadFormatVersion: "2.0" + PayloadFormatVersion: '2.0' Path: /basic Method: post ApiId: !Ref MyApi @@ -44,14 +46,14 @@ Resources: FunctionInvokeRole: !GetAtt MyAuthFnRole.Arn Identity: Context: - - contextVar + - contextVar Headers: - - Authorization + - Authorization QueryStrings: - - petId + - petId StageVariables: - - stageVar + - stageVar ReauthorizeEvery: 60 AuthorizerPayloadFormatVersion: 2.0 EnableSimpleResponses: true - DefaultAuthorizer: LambdaAuth \ No newline at end of file + DefaultAuthorizer: LambdaAuth diff --git a/tests/functional/commands/validate/lib/models/http_api_local_iam_auth_enabled.yaml b/tests/functional/commands/validate/lib/models/http_api_local_iam_auth_enabled.yaml index 50c7c38fee..ef339c1644 100644 --- a/tests/functional/commands/validate/lib/models/http_api_local_iam_auth_enabled.yaml +++ b/tests/functional/commands/validate/lib/models/http_api_local_iam_auth_enabled.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: HttpApi: Auth: @@ -74,4 +76,4 @@ Resources: Type: AWS::Serverless::HttpApi Properties: Auth: - EnableIamAuthorizer: true \ No newline at end of file + EnableIamAuthorizer: true diff --git a/tests/functional/commands/validate/lib/models/http_api_local_iam_auth_enabled_with_existing_conflicting_authorizer.yaml b/tests/functional/commands/validate/lib/models/http_api_local_iam_auth_enabled_with_existing_conflicting_authorizer.yaml index 38430e67cc..ee04e04e04 100644 --- a/tests/functional/commands/validate/lib/models/http_api_local_iam_auth_enabled_with_existing_conflicting_authorizer.yaml +++ b/tests/functional/commands/validate/lib/models/http_api_local_iam_auth_enabled_with_existing_conflicting_authorizer.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- # This test-case tests what happens when an AWS_IAM authorizer is defined on an HttpApi and also enabled locally. # In this case the defined authorizer should NOT be overwritten. Resources: @@ -8,12 +10,12 @@ Resources: Authorizers: AWS_IAM: AuthorizationScopes: - - scope + - scope IdentitySource: $request.header.Authorization JwtConfiguration: audience: - - audience1 - - audience2 - issuer: "https://www.example.com/v1/connect/oidc" + - audience1 + - audience2 + issuer: https://www.example.com/v1/connect/oidc DefaultAuthorizer: AWS_IAM EnableIamAuthorizer: true diff --git a/tests/functional/commands/validate/lib/models/http_api_multiple_authorizers.yaml b/tests/functional/commands/validate/lib/models/http_api_multiple_authorizers.yaml index cb5633c83c..3c39007f93 100644 --- a/tests/functional/commands/validate/lib/models/http_api_multiple_authorizers.yaml +++ b/tests/functional/commands/validate/lib/models/http_api_multiple_authorizers.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HttpApiFunction: Type: AWS::Serverless::Function @@ -59,12 +61,12 @@ Resources: AuthorizerPayloadFormatVersion: 1.0 MyOauth2Authorizer: AuthorizationScopes: - - scope + - scope IdentitySource: $request.header.Authorization JwtConfiguration: audience: - - audience1 - - audience2 - issuer: "https://www.example.com/v1/connect/oidc" + - audience1 + - audience2 + issuer: https://www.example.com/v1/connect/oidc DefaultAuthorizer: LambdaAuth EnableIamAuthorizer: true diff --git a/tests/functional/commands/validate/lib/models/http_api_with_cors.yaml b/tests/functional/commands/validate/lib/models/http_api_with_cors.yaml index 0c0ebee49c..76d9797834 100644 --- a/tests/functional/commands/validate/lib/models/http_api_with_cors.yaml +++ b/tests/functional/commands/validate/lib/models/http_api_with_cors.yaml @@ -1,37 +1,39 @@ +%YAML 1.1 +--- Conditions: C1: Fn::Equals: - - true - - true + - true + - true Globals: HttpApi: CorsConfiguration: Fn::If: - - C1 - - AllowHeaders: - - x-apigateway-header - AllowMethods: - - GET - AllowOrigins: - - https://foo.com - ExposeHeaders: - - x-amzn-header - - AWS::NoValue + - C1 + - AllowHeaders: + - x-apigateway-header + AllowMethods: + - GET + AllowOrigins: + - https://foo.com + ExposeHeaders: + - x-amzn-header + - AWS::NoValue Resources: HttpApiFunction: Type: AWS::Serverless::Function Properties: InlineCode: | - exports.handler = async (event) => { - console.log("Hello from MyAuthFunction") - return { - statusCode: 200, - body: JSON.stringify(event), - headers: {} - } - } + exports.handler = async (event) => { + console.log("Hello from MyAuthFunction") + return { + statusCode: 200, + body: JSON.stringify(event), + headers: {} + } + } Handler: index.handler Runtime: nodejs12.x Events: @@ -51,7 +53,7 @@ Resources: title: Ref: AWS::StackName paths: - "$default": + $default: x-amazon-apigateway-any-method: isDefaultRoute: true - openapi: 3.0.1 \ No newline at end of file + openapi: 3.0.1 diff --git a/tests/functional/commands/validate/lib/models/http_api_with_custom_domain_route53_multiple.yaml b/tests/functional/commands/validate/lib/models/http_api_with_custom_domain_route53_multiple.yaml index 21832b61dd..256d8f171d 100644 --- a/tests/functional/commands/validate/lib/models/http_api_with_custom_domain_route53_multiple.yaml +++ b/tests/functional/commands/validate/lib/models/http_api_with_custom_domain_route53_multiple.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: MyApi1: Type: AWS::Serverless::HttpApi @@ -7,7 +9,7 @@ Resources: CertificateArn: arn::cert::abc EndpointConfiguration: REGIONAL Route53: - HostedZoneId: "abc123456" + HostedZoneId: abc123456 MyApi2: Type: AWS::Serverless::HttpApi @@ -17,7 +19,7 @@ Resources: CertificateArn: arn::cert::abc EndpointConfiguration: REGIONAL Route53: - HostedZoneId: "abc123456" + HostedZoneId: abc123456 MyApi3: Type: AWS::Serverless::HttpApi @@ -27,4 +29,4 @@ Resources: CertificateArn: arn::cert::abc EndpointConfiguration: REGIONAL Route53: - HostedZoneId: "abc123456" \ No newline at end of file + HostedZoneId: abc123456 diff --git a/tests/functional/commands/validate/lib/models/http_api_with_null_path.yaml b/tests/functional/commands/validate/lib/models/http_api_with_null_path.yaml index ce2018446e..9665be77c8 100644 --- a/tests/functional/commands/validate/lib/models/http_api_with_null_path.yaml +++ b/tests/functional/commands/validate/lib/models/http_api_with_null_path.yaml @@ -1,6 +1,9 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' -Transform: 'AWS::Serverless-2016-10-31' -Description: A template to test for API condition handling with a mix of explicit and implicit api events. +Transform: AWS::Serverless-2016-10-31 +Description: A template to test for API condition handling with a mix of explicit + and implicit api events. Resources: EXAMPLEPARTIALGateway: @@ -10,7 +13,7 @@ Resources: openapi: 3.0.1 paths: /my/route: - post: null + post: EXAMPLEPARTIALLambda: Type: AWS::Serverless::Function Properties: @@ -24,4 +27,4 @@ Resources: Path: /my/route ApiId: Ref: EXAMPLEPARTIALGateway - Method: POST \ No newline at end of file + Method: POST diff --git a/tests/functional/commands/validate/lib/models/implicit_and_explicit_api_with_conditions.yaml b/tests/functional/commands/validate/lib/models/implicit_and_explicit_api_with_conditions.yaml index aaae92b6a8..2063e4039c 100644 --- a/tests/functional/commands/validate/lib/models/implicit_and_explicit_api_with_conditions.yaml +++ b/tests/functional/commands/validate/lib/models/implicit_and_explicit_api_with_conditions.yaml @@ -1,27 +1,30 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' -Transform: 'AWS::Serverless-2016-10-31' -Description: A template to test for API condition handling with a mix of explicit and implicit api events. +Transform: AWS::Serverless-2016-10-31 +Description: A template to test for API condition handling with a mix of explicit + and implicit api events. Conditions: implicithello1condition: Fn::Equals: - - true - - false + - true + - false implicithello2condition: Fn::Equals: - - true - - false + - true + - false explicithello1condition: Fn::Equals: - - true - - false + - true + - false explicithello2condition: Fn::Equals: - - true - - false + - true + - false Resources: implicithello1: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: implicithello1condition Properties: Handler: index.handler @@ -37,7 +40,7 @@ Resources: Path: /implicit/hello1 Method: get implicithello2: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: implicithello2condition Properties: Handler: index.handler @@ -54,11 +57,11 @@ Resources: Method: get explicitapi: - Type: 'AWS::Serverless::Api' + Type: AWS::Serverless::Api Properties: StageName: Prod explicithello1: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: explicithello1condition Properties: Handler: index.handler @@ -75,7 +78,7 @@ Resources: Path: /explicit/hello1 Method: get explicithello2: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: explicithello2condition Properties: Handler: index.handler diff --git a/tests/functional/commands/validate/lib/models/implicit_api.yaml b/tests/functional/commands/validate/lib/models/implicit_api.yaml index bb4e5a2875..55d8f8120f 100644 --- a/tests/functional/commands/validate/lib/models/implicit_api.yaml +++ b/tests/functional/commands/validate/lib/models/implicit_api.yaml @@ -1,5 +1,7 @@ +%YAML 1.1 +--- Resources: - RestApiFunction: + RestApiFunction: Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/todo_list.zip diff --git a/tests/functional/commands/validate/lib/models/implicit_api_deletion_policy_precedence.yaml b/tests/functional/commands/validate/lib/models/implicit_api_deletion_policy_precedence.yaml index 643b9ac477..862c9b4780 100644 --- a/tests/functional/commands/validate/lib/models/implicit_api_deletion_policy_precedence.yaml +++ b/tests/functional/commands/validate/lib/models/implicit_api_deletion_policy_precedence.yaml @@ -1,5 +1,7 @@ +%YAML 1.1 +--- Resources: - RestApiFunction: + RestApiFunction: Type: AWS::Serverless::Function DeletionPolicy: Delete UpdateReplacePolicy: Retain diff --git a/tests/functional/commands/validate/lib/models/implicit_api_with_auth_and_conditions_max.yaml b/tests/functional/commands/validate/lib/models/implicit_api_with_auth_and_conditions_max.yaml index e32f9206e2..cb7c039135 100644 --- a/tests/functional/commands/validate/lib/models/implicit_api_with_auth_and_conditions_max.yaml +++ b/tests/functional/commands/validate/lib/models/implicit_api_with_auth_and_conditions_max.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Globals: Api: Auth: @@ -11,8 +13,8 @@ Globals: MyCognitoAuthMultipleUserPools: UserPoolArn: - - arn:aws:2 - - arn:aws:3 + - arn:aws:2 + - arn:aws:3 Identity: Header: MyAuthorizationHeader2 ValidationExpression: myauthvalidationexpression2 @@ -38,40 +40,40 @@ Globals: FunctionInvokeRole: arn:aws:iam::123456789012:role/S3Access Identity: Headers: - - Authorization1 + - Authorization1 QueryStrings: - - Authorization2 + - Authorization2 StageVariables: - - Authorization3 + - Authorization3 Context: - - Authorization4 + - Authorization4 ReauthorizeEvery: 0 Conditions: FunctionCondition: Fn::Equals: - - true - - false + - true + - false FunctionCondition2: Fn::Equals: - - true - - false + - true + - false FunctionCondition3: Fn::Equals: - - true - - false + - true + - false FunctionCondition4: Fn::Equals: - - true - - false + - true + - false FunctionCondition5: Fn::Equals: - - true - - false + - true + - false FunctionCondition6: Fn::Equals: - - true - - false + - true + - false Resources: MyFunction: @@ -163,4 +165,4 @@ Resources: Path: /users Method: put Auth: - ApiKeyRequired: true \ No newline at end of file + ApiKeyRequired: true diff --git a/tests/functional/commands/validate/lib/models/implicit_api_with_many_conditions.yaml b/tests/functional/commands/validate/lib/models/implicit_api_with_many_conditions.yaml index 4c0b926cb9..14bae0537a 100644 --- a/tests/functional/commands/validate/lib/models/implicit_api_with_many_conditions.yaml +++ b/tests/functional/commands/validate/lib/models/implicit_api_with_many_conditions.yaml @@ -1,55 +1,57 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' -Transform: 'AWS::Serverless-2016-10-31' +Transform: AWS::Serverless-2016-10-31 Description: A template to test for implicit API condition handling. Conditions: MyCondition: Fn::Equals: - - true - - false + - true + - false Cond: Fn::Equals: - - true - - false + - true + - false Cond1: Fn::Equals: - - true - - false + - true + - false Cond2: Fn::Equals: - - true - - false + - true + - false Cond3: Fn::Equals: - - true - - false + - true + - false Cond4: Fn::Equals: - - true - - false + - true + - false Cond5: Fn::Equals: - - true - - false + - true + - false Cond6: Fn::Equals: - - true - - false + - true + - false Cond7: Fn::Equals: - - true - - false + - true + - false Cond8: Fn::Equals: - - true - - false + - true + - false Cond9: Fn::Equals: - - true - - false + - true + - false Resources: hello: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: MyCondition Properties: Handler: index.handler @@ -65,7 +67,7 @@ Resources: Path: /sub Method: get helloworld: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond Properties: Handler: index.handler @@ -79,9 +81,9 @@ Resources: Type: Api Properties: Path: /sub - Method: post + Method: post helloworld1: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond1 Properties: Handler: index.handler @@ -95,9 +97,9 @@ Resources: Type: Api Properties: Path: /sub1 - Method: post + Method: post helloworld2: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond2 Properties: Handler: index.handler @@ -111,9 +113,9 @@ Resources: Type: Api Properties: Path: /sub2 - Method: post + Method: post helloworld3: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond3 Properties: Handler: index.handler @@ -127,9 +129,9 @@ Resources: Type: Api Properties: Path: /sub3 - Method: post + Method: post helloworld4: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond4 Properties: Handler: index.handler @@ -143,9 +145,9 @@ Resources: Type: Api Properties: Path: /sub4 - Method: post + Method: post helloworld5: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond5 Properties: Handler: index.handler @@ -159,9 +161,9 @@ Resources: Type: Api Properties: Path: /sub5 - Method: post + Method: post helloworld6: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond6 Properties: Handler: index.handler @@ -175,9 +177,9 @@ Resources: Type: Api Properties: Path: /sub6 - Method: post + Method: post helloworld7: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond7 Properties: Handler: index.handler @@ -191,9 +193,9 @@ Resources: Type: Api Properties: Path: /sub7 - Method: post + Method: post helloworld8: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond8 Properties: Handler: index.handler @@ -207,9 +209,9 @@ Resources: Type: Api Properties: Path: /sub8 - Method: post + Method: post helloworld9: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond9 Properties: Handler: index.handler @@ -223,4 +225,4 @@ Resources: Type: Api Properties: Path: /sub9 - Method: post + Method: post diff --git a/tests/functional/commands/validate/lib/models/implicit_api_with_serverless_rest_api_resource.yaml b/tests/functional/commands/validate/lib/models/implicit_api_with_serverless_rest_api_resource.yaml index 1b6497808f..9addfa3a94 100644 --- a/tests/functional/commands/validate/lib/models/implicit_api_with_serverless_rest_api_resource.yaml +++ b/tests/functional/commands/validate/lib/models/implicit_api_with_serverless_rest_api_resource.yaml @@ -1,5 +1,7 @@ +%YAML 1.1 +--- Resources: - RestApiFunction: + RestApiFunction: Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/todo_list.zip @@ -38,7 +40,7 @@ Resources: Method: any ServerlessRestApi: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler diff --git a/tests/functional/commands/validate/lib/models/implicit_http_api.yaml b/tests/functional/commands/validate/lib/models/implicit_http_api.yaml index ee141d7d55..4f8047964a 100644 --- a/tests/functional/commands/validate/lib/models/implicit_http_api.yaml +++ b/tests/functional/commands/validate/lib/models/implicit_http_api.yaml @@ -1,5 +1,7 @@ +%YAML 1.1 +--- Resources: - HttpApiFunction: + HttpApiFunction: Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/todo_list.zip @@ -15,7 +17,7 @@ Resources: SimpleCase: Type: HttpApi - HttpApiFunction2: + HttpApiFunction2: Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/todo_list.zip diff --git a/tests/functional/commands/validate/lib/models/implicit_http_api_auth_and_simple_case.yaml b/tests/functional/commands/validate/lib/models/implicit_http_api_auth_and_simple_case.yaml index 944e7c8400..75104c05eb 100644 --- a/tests/functional/commands/validate/lib/models/implicit_http_api_auth_and_simple_case.yaml +++ b/tests/functional/commands/validate/lib/models/implicit_http_api_auth_and_simple_case.yaml @@ -1,5 +1,7 @@ +%YAML 1.1 +--- Resources: - RestApiFunction: + RestApiFunction: Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/todo_list.zip @@ -26,7 +28,7 @@ Resources: Method: post Auth: AuthorizationScopes: - - scope3 + - scope3 oauth2Path: Type: HttpApi Properties: @@ -43,10 +45,10 @@ Globals: Authorizers: oauth2Auth: AuthorizationScopes: - - scope4 + - scope4 JwtConfiguration: - issuer: "https://www.example.com/v1/connect/oidc" + issuer: https://www.example.com/v1/connect/oidc audience: - - MyApi - IdentitySource: "$request.querystring.param" + - MyApi + IdentitySource: $request.querystring.param DefaultAuthorizer: oauth2Auth diff --git a/tests/functional/commands/validate/lib/models/implicit_http_api_with_many_conditions.yaml b/tests/functional/commands/validate/lib/models/implicit_http_api_with_many_conditions.yaml index 47dad4bd63..eaaa26bade 100644 --- a/tests/functional/commands/validate/lib/models/implicit_http_api_with_many_conditions.yaml +++ b/tests/functional/commands/validate/lib/models/implicit_http_api_with_many_conditions.yaml @@ -1,69 +1,71 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' -Transform: 'AWS::Serverless-2016-10-31' +Transform: AWS::Serverless-2016-10-31 Description: A template to test for implicit HttpApi condition handling. Conditions: MyCondition: Fn::Equals: - - true - - false + - true + - false Cond: Fn::Equals: - - true - - false + - true + - false Cond1: Fn::Equals: - - true - - false + - true + - false Cond2: Fn::Equals: - - true - - false + - true + - false Cond3: Fn::Equals: - - true - - false + - true + - false Cond4: Fn::Equals: - - true - - false + - true + - false Cond5: Fn::Equals: - - true - - false + - true + - false Cond6: Fn::Equals: - - true - - false + - true + - false Cond7: Fn::Equals: - - true - - false + - true + - false Cond8: Fn::Equals: - - true - - false + - true + - false Cond9: Fn::Equals: - - true - - false + - true + - false Globals: HttpApi: RouteSettings: - "GET /sub": + GET /sub: ThrottlingBurstLimit: 100 Auth: Authorizers: oauth2: AuthorizationScopes: - - scope4 + - scope4 JwtConfiguration: - issuer: "https://www.example.com/v1/connect/oidc" + issuer: https://www.example.com/v1/connect/oidc audience: - - MyApi - IdentitySource: "$request.querystring.param" + - MyApi + IdentitySource: $request.querystring.param Resources: hello: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: MyCondition Properties: Handler: index.handler @@ -81,7 +83,7 @@ Resources: Path: /sub Method: get helloworld1099: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond Properties: Handler: index.handler @@ -104,7 +106,7 @@ Resources: Path: /hello/again Method: get helloworld1: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond1 Properties: Handler: index.handler @@ -118,9 +120,9 @@ Resources: Type: HttpApi Properties: Path: /sub1 - Method: post + Method: post helloworld2: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond2 Properties: Handler: index.handler @@ -134,9 +136,9 @@ Resources: Type: HttpApi Properties: Path: /sub2 - Method: post + Method: post helloworld3: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond3 Properties: Handler: index.handler @@ -150,9 +152,9 @@ Resources: Type: HttpApi Properties: Path: /sub3 - Method: post + Method: post helloworld4: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond4 Properties: Handler: index.handler @@ -166,9 +168,9 @@ Resources: Type: HttpApi Properties: Path: /sub4 - Method: post + Method: post helloworld5: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond5 Properties: Handler: index.handler @@ -182,9 +184,9 @@ Resources: Type: HttpApi Properties: Path: /sub5 - Method: post + Method: post helloworld6: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond6 Properties: Handler: index.handler @@ -198,9 +200,9 @@ Resources: Type: HttpApi Properties: Path: /sub6 - Method: post + Method: post helloworld7: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond7 Properties: Handler: index.handler @@ -214,9 +216,9 @@ Resources: Type: HttpApi Properties: Path: /sub7 - Method: post + Method: post helloworld8: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond8 Properties: Handler: index.handler @@ -230,9 +232,9 @@ Resources: Type: HttpApi Properties: Path: /sub8 - Method: post + Method: post helloworld9: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Condition: Cond9 Properties: Handler: index.handler @@ -246,4 +248,4 @@ Resources: Type: HttpApi Properties: Path: /sub9 - Method: post + Method: post diff --git a/tests/functional/commands/validate/lib/models/inline_precedence.yaml b/tests/functional/commands/validate/lib/models/inline_precedence.yaml index 04812fb297..3f2e192a40 100644 --- a/tests/functional/commands/validate/lib/models/inline_precedence.yaml +++ b/tests/functional/commands/validate/lib/models/inline_precedence.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: HelloWorldFunction: Type: AWS::Serverless::Function @@ -7,4 +9,4 @@ Resources: pass" CodeUri: . Handler: index.lambda_handler - Runtime: python3.8 \ No newline at end of file + Runtime: python3.8 diff --git a/tests/functional/commands/validate/lib/models/intrinsic_functions.yaml b/tests/functional/commands/validate/lib/models/intrinsic_functions.yaml index 7ce6df0625..e331765df1 100644 --- a/tests/functional/commands/validate/lib/models/intrinsic_functions.yaml +++ b/tests/functional/commands/validate/lib/models/intrinsic_functions.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- # SAM template using intrinsic function on every property that supports it. # Translator should handle it properly Parameters: @@ -15,7 +17,7 @@ Parameters: Default: SomeName CodeKey: Type: String - Default: "key" + Default: key RoleFieldName: Type: String Default: Role @@ -23,12 +25,12 @@ Parameters: Conditions: TrueCondition: Fn::Equals: - - true - - true + - true + - true Resources: MyFunction: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: FunctionName: Fn::Sub: ${FunctionName} @@ -36,18 +38,18 @@ Resources: Bucket: Ref: CodeBucket Key: - "Fn::Sub": "code.zip.${CodeKey}" + Fn::Sub: code.zip.${CodeKey} Version: - "Fn::Join": ["", ["some", "version"]] + Fn::Join: ['', [some, version]] Handler: - "Fn::Sub": ["${filename}.handler", { filename: "index" }] + Fn::Sub: ['${filename}.handler', filename: index] Runtime: - "Fn::Join": ["", ["nodejs", "4.3"]] + Fn::Join: ['', [nodejs, '4.3']] Role: - "Fn::GetAtt": ["MyNewRole", "Arn"] + Fn::GetAtt: [MyNewRole, Arn] Tracing: Ref: TracingConfigParam @@ -59,7 +61,7 @@ Resources: Path: / Method: GET RestApiId: - "Ref": "MyExplicitApi" + Ref: MyExplicitApi MyExplicitApi: Type: AWS::Serverless::Api @@ -70,9 +72,9 @@ Resources: StageName: dev Variables: FunctionName: - Fn::Sub: "${MyFunction}" + Fn::Sub: ${MyFunction} Var2: - Fn::Join: ["join ", ["some value ", "with some other value"]] + Fn::Join: ['join ', ['some value ', with some other value]] FunctionWithExplicitS3Uri: Type: AWS::Serverless::Function @@ -95,7 +97,7 @@ Resources: Version: 3 DynamoDBFunction: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/streams.zip Handler: stream.ddb_handler @@ -105,31 +107,29 @@ Resources: Type: DynamoDB Properties: Stream: - Fn::GetAtt: [MyTable, "StreamArn"] + Fn::GetAtt: [MyTable, StreamArn] BatchSize: 200 StartingPosition: LATEST FilterCriteria: Fn::Select: - - "1" - - - - {} - - { "Filters": { "Pattern": "{\"value\": \"b\"}" }} - + - '1' + - - {} + - {Filters: {Pattern: '{"value": "b"}'}} MyTable: Type: AWS::DynamoDB::Table Properties: AttributeDefinitions: - - { AttributeName: id, AttributeType: S } + - {AttributeName: id, AttributeType: S} KeySchema: - - { "AttributeName": "id", "KeyType": "HASH" } + - {AttributeName: id, KeyType: HASH} ProvisionedThroughput: ReadCapacityUnits: 5 WriteCapacityUnits: 5 StreamSpecification: - StreamViewType: "NEW_IMAGE" + StreamViewType: NEW_IMAGE MySqsDlqLambdaFunction: Type: AWS::Serverless::Function @@ -141,8 +141,8 @@ Resources: Type: SQS TargetArn: Fn::GetAtt: - - SqsDlqQueue - - Arn + - SqsDlqQueue + - Arn SqsDlqQueue: Type: AWS::SQS::Queue @@ -166,19 +166,19 @@ Resources: Properties: AssumeRolePolicyDocument: Statement: - - Action: ["sts:AssumeRole"] - Effect: Allow - Principal: - Service: [lambda.amazonaws.com] - Version: "2012-10-17" + - Action: [sts:AssumeRole] + Effect: Allow + Principal: + Service: [lambda.amazonaws.com] + Version: '2012-10-17' Policies: - - PolicyDocument: - Statement: - - Action: ["cloudwatch:*", "logs:*"] - Effect: Allow - Resource: "*" - Version: "2012-10-17" - PolicyName: lambdaRole + - PolicyDocument: + Statement: + - Action: [cloudwatch:*, logs:*] + Effect: Allow + Resource: '*' + Version: '2012-10-17' + PolicyName: lambdaRole MyOtherFunction: Type: AWS::Serverless::Function @@ -195,6 +195,5 @@ Resources: Runtime: python2.7 Role: Fn::GetAtt: - - MyOtherFunction - - Fn::Ref: - RoleFieldName + - MyOtherFunction + - Fn::Ref: RoleFieldName diff --git a/tests/functional/commands/validate/lib/models/iot_rule.yaml b/tests/functional/commands/validate/lib/models/iot_rule.yaml index b6c1f98463..c4a45ed0e2 100644 --- a/tests/functional/commands/validate/lib/models/iot_rule.yaml +++ b/tests/functional/commands/validate/lib/models/iot_rule.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- # File: sam.yml # Version: 0.9 @@ -23,4 +25,3 @@ Resources: MemorySize: 1024 Runtime: nodejs12.x Timeout: 3 - diff --git a/tests/functional/commands/validate/lib/models/kinesis_intrinsics.yaml b/tests/functional/commands/validate/lib/models/kinesis_intrinsics.yaml index 7107cb06ad..ebd97f6f8c 100644 --- a/tests/functional/commands/validate/lib/models/kinesis_intrinsics.yaml +++ b/tests/functional/commands/validate/lib/models/kinesis_intrinsics.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: IntValue: Type: Number @@ -18,12 +20,12 @@ Parameters: Conditions: TrueCondition: Fn::Equals: - - true - - true + - true + - true FalseCondition: Fn::Equals: - - true - - false + - true + - false Resources: MyLambdaFunction: @@ -42,16 +44,16 @@ Resources: Ref: IntValue BisectBatchOnFunctionError: Fn::If: - - FalseCondition - - True - - False + - FalseCondition + - true + - false Enabled: Fn::If: - - TrueCondition - - True - - False + - TrueCondition + - true + - false FunctionResponseTypes: - - Ref: FunctionResponseTypesValue + - Ref: FunctionResponseTypesValue MaximumBatchingWindowInSeconds: Ref: IntValue MaximumRecordAgeInSeconds: @@ -65,15 +67,15 @@ Resources: Stream: # Connect with the stream we have created in this template Fn::Join: - - '' - - - 'arn:' - - Ref: AWS::Partition - - ':kinesis:' - - Ref: AWS::Region - - ':' - - Ref: AWS::AccountId - - ':stream/' - - Ref: MyStream + - '' + - - 'arn:' + - Ref: AWS::Partition + - ':kinesis:' + - Ref: AWS::Region + - ':' + - Ref: AWS::AccountId + - :stream/ + - Ref: MyStream TumblingWindowInSeconds: Ref: IntValue MyStream: diff --git a/tests/functional/commands/validate/lib/models/layer_deletion_policy_precedence.yaml b/tests/functional/commands/validate/lib/models/layer_deletion_policy_precedence.yaml index a967ed6212..adfbce1ad2 100644 --- a/tests/functional/commands/validate/lib/models/layer_deletion_policy_precedence.yaml +++ b/tests/functional/commands/validate/lib/models/layer_deletion_policy_precedence.yaml @@ -1,18 +1,20 @@ +%YAML 1.1 +--- Resources: MinimalLayer: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion DeletionPolicy: Delete Properties: ContentUri: s3://sam-demo-bucket/layer.zip RetentionPolicy: Retain MinimalLayer2: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion DeletionPolicy: Delete Properties: ContentUri: s3://sam-demo-bucket/layer.zip MinimalLayer3: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: - ContentUri: s3://sam-demo-bucket/layer.zip \ No newline at end of file + ContentUri: s3://sam-demo-bucket/layer.zip diff --git a/tests/functional/commands/validate/lib/models/layers_all_properties.yaml b/tests/functional/commands/validate/lib/models/layers_all_properties.yaml index 03fef5dbc2..89d692a70f 100644 --- a/tests/functional/commands/validate/lib/models/layers_all_properties.yaml +++ b/tests/functional/commands/validate/lib/models/layers_all_properties.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: LayerDeleteParam: Type: String @@ -5,25 +7,25 @@ Parameters: Resources: MyLayer: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: ContentUri: s3://bucket/key RetentionPolicy: !Ref LayerDeleteParam MyLayerWithAName: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: ContentUri: s3://bucket/key LayerName: DifferentLayerName MyFunction: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://bucket/key Handler: app.handler Runtime: python3.6 Layers: - - !Ref MyLayer + - !Ref MyLayer Outputs: LayerName: diff --git a/tests/functional/commands/validate/lib/models/layers_with_intrinsics.yaml b/tests/functional/commands/validate/lib/models/layers_with_intrinsics.yaml index 28a4e23029..3e7945d0e2 100644 --- a/tests/functional/commands/validate/lib/models/layers_with_intrinsics.yaml +++ b/tests/functional/commands/validate/lib/models/layers_with_intrinsics.yaml @@ -1,10 +1,12 @@ +%YAML 1.1 +--- Parameters: CompatibleArchitecturesList: Type: CommaDelimitedList Default: arm64,x86_64 CompatibleArchitecturesRef: Type: String - Default: 'arm64' + Default: arm64 LayerNameParam: Type: String Default: SomeLayerName @@ -19,32 +21,32 @@ Parameters: Resources: LayerWithLicenseIntrinsic: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: ContentUri: s3://sam-demo-bucket/layer.zip LicenseInfo: !Ref LayerLicenseInfo LayerWithRuntimesIntrinsic: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: ContentUri: s3://sam-demo-bucket/layer.zip CompatibleRuntimes: Ref: LayerRuntimeList LayerWithSingleListRefRuntimesIntrinsic: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: ContentUri: s3://sam-demo-bucket/layer.zip CompatibleRuntimes: - - Ref: LayerRuntimeRefString + - Ref: LayerRuntimeRefString LayerWithMixedListRefRuntimesIntrinsic: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: ContentUri: s3://sam-demo-bucket/layer.zip CompatibleRuntimes: - - Ref: LayerRuntimeString - - 'SomeRuntimeNameString' + - Ref: LayerRuntimeString + - SomeRuntimeNameString LayerWithNameIntrinsic: Type: AWS::Serverless::LayerVersion @@ -71,16 +73,15 @@ Resources: LayerName: !Sub 'layer-${AWS::Region}' LayerWithArchitecturesIntrinsic: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: ContentUri: s3://sam-demo-bucket/layer.zip CompatibleArchitectures: Ref: CompatibleArchitecturesList LayerWithSingleListRefArchitecturesIntrinsic: - Type: 'AWS::Serverless::LayerVersion' + Type: AWS::Serverless::LayerVersion Properties: ContentUri: s3://sam-demo-bucket/layer.zip CompatibleArchitectures: - - Ref: CompatibleArchitecturesRef - + - Ref: CompatibleArchitecturesRef diff --git a/tests/functional/commands/validate/lib/models/mixed_api_with_custom_domain_route53_multiple.yaml b/tests/functional/commands/validate/lib/models/mixed_api_with_custom_domain_route53_multiple.yaml index 7461e530cb..6fdc6bf24d 100644 --- a/tests/functional/commands/validate/lib/models/mixed_api_with_custom_domain_route53_multiple.yaml +++ b/tests/functional/commands/validate/lib/models/mixed_api_with_custom_domain_route53_multiple.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > @@ -14,7 +16,7 @@ Resources: CertificateArn: arn::cert::abc EndpointConfiguration: REGIONAL Route53: - HostedZoneId: "abc123456" + HostedZoneId: abc123456 MyRestApi: Type: AWS::Serverless::Api @@ -23,14 +25,14 @@ Resources: StageName: Prod TracingEnabled: true MethodSettings: - - LoggingLevel: Info - ResourcePath: '/*' - HttpMethod: '*' + - LoggingLevel: Info + ResourcePath: /* + HttpMethod: '*' Domain: DomainName: admin.two.amazon.com CertificateArn: arn::cert::abc EndpointConfiguration: REGIONAL Route53: - HostedZoneId: "abc123456" + HostedZoneId: abc123456 EndpointConfiguration: Type: REGIONAL diff --git a/tests/functional/commands/validate/lib/models/no_implicit_api_with_serverless_rest_api_resource.yaml b/tests/functional/commands/validate/lib/models/no_implicit_api_with_serverless_rest_api_resource.yaml index 84e478a3b5..bfb5ce4cf6 100644 --- a/tests/functional/commands/validate/lib/models/no_implicit_api_with_serverless_rest_api_resource.yaml +++ b/tests/functional/commands/validate/lib/models/no_implicit_api_with_serverless_rest_api_resource.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: ThumbnailFunction: Type: AWS::Serverless::Function @@ -22,7 +24,7 @@ Resources: title: Ref: AWS::StackName paths: - "/add": + /add: post: x-amazon-apigateway-integration: httpMethod: POST @@ -30,7 +32,7 @@ Resources: uri: Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${RestApiFunction.Arn}/invocations responses: {} - "/{proxy+}": + /{proxy+}: x-amazon-apigateway-any-method: x-amazon-apigateway-integration: httpMethod: POST @@ -38,7 +40,7 @@ Resources: uri: Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetHtmlFunction.Arn}/invocations responses: {} - "/getlist": + /getlist: get: x-amazon-apigateway-integration: httpMethod: POST @@ -46,7 +48,7 @@ Resources: uri: Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${RestApiFunction.Arn}/invocations responses: {} - "/complete": + /complete: post: x-amazon-apigateway-integration: httpMethod: POST @@ -60,15 +62,15 @@ Resources: Type: AWS::S3::Bucket RestApiFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python3.6 GetHtmlFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler - Runtime: python3.6 \ No newline at end of file + Runtime: python3.6 diff --git a/tests/functional/commands/validate/lib/models/resource_with_invalid_type.yaml b/tests/functional/commands/validate/lib/models/resource_with_invalid_type.yaml index 46ace54610..0e8c08087e 100644 --- a/tests/functional/commands/validate/lib/models/resource_with_invalid_type.yaml +++ b/tests/functional/commands/validate/lib/models/resource_with_invalid_type.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: FunctionInvalid: Type: diff --git a/tests/functional/commands/validate/lib/models/s3.yaml b/tests/functional/commands/validate/lib/models/s3.yaml index 69e100da5f..14dfc02455 100644 --- a/tests/functional/commands/validate/lib/models/s3.yaml +++ b/tests/functional/commands/validate/lib/models/s3.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: ThumbnailFunction: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/s3_create_remove.yaml b/tests/functional/commands/validate/lib/models/s3_create_remove.yaml index f14cf2a4f4..90dec53581 100644 --- a/tests/functional/commands/validate/lib/models/s3_create_remove.yaml +++ b/tests/functional/commands/validate/lib/models/s3_create_remove.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: ThumbnailFunction: Type: AWS::Serverless::Function @@ -18,8 +20,8 @@ Resources: Images: Type: AWS::S3::Bucket Properties: - BucketName: "BucketNameParameter" - BucketEncryption: - ServerSideEncryptionConfiguration: - - ServerSideEncryptionByDefault: - SSEAlgorithm: AES256 + BucketName: BucketNameParameter + BucketEncryption: + ServerSideEncryptionConfiguration: + - ServerSideEncryptionByDefault: + SSEAlgorithm: AES256 diff --git a/tests/functional/commands/validate/lib/models/s3_existing_lambda_notification_configuration.yaml b/tests/functional/commands/validate/lib/models/s3_existing_lambda_notification_configuration.yaml index 045381426b..aa1b8c9304 100644 --- a/tests/functional/commands/validate/lib/models/s3_existing_lambda_notification_configuration.yaml +++ b/tests/functional/commands/validate/lib/models/s3_existing_lambda_notification_configuration.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: ThumbnailFunction: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/s3_existing_other_notification_configuration.yaml b/tests/functional/commands/validate/lib/models/s3_existing_other_notification_configuration.yaml index a4bd945a6a..24e7c89ec0 100644 --- a/tests/functional/commands/validate/lib/models/s3_existing_other_notification_configuration.yaml +++ b/tests/functional/commands/validate/lib/models/s3_existing_other_notification_configuration.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: ThumbnailFunction: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/s3_filter.yaml b/tests/functional/commands/validate/lib/models/s3_filter.yaml index 0f6acefd5a..2fa0750ccc 100644 --- a/tests/functional/commands/validate/lib/models/s3_filter.yaml +++ b/tests/functional/commands/validate/lib/models/s3_filter.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: ThumbnailFunction: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/s3_intrinsics.yaml b/tests/functional/commands/validate/lib/models/s3_intrinsics.yaml index dff8fe9802..189bd63971 100644 --- a/tests/functional/commands/validate/lib/models/s3_intrinsics.yaml +++ b/tests/functional/commands/validate/lib/models/s3_intrinsics.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: EventsParam: Type: String @@ -6,8 +8,8 @@ Parameters: Conditions: MyCondition: Fn::Equals: - - true - - false + - true + - false Resources: ThumbnailFunction: @@ -23,18 +25,18 @@ Resources: Bucket: Ref: Images Events: - - s3:ObjectCreated:* + - s3:ObjectCreated:* Filter: Fn::If: - - MyCondition - - S3Key: - Rules: - - Name: Rule1Prefix - Value: Rule1Value - - S3Key: - Rules: - - Name: Rule2Prefix - Value: Rule2Value + - MyCondition + - S3Key: + Rules: + - Name: Rule1Prefix + Value: Rule1Value + - S3Key: + Rules: + - Name: Rule2Prefix + Value: Rule2Value Images: Type: AWS::S3::Bucket diff --git a/tests/functional/commands/validate/lib/models/s3_multiple_events_same_bucket.yaml b/tests/functional/commands/validate/lib/models/s3_multiple_events_same_bucket.yaml index 63c396d624..fa47e2fdf2 100644 --- a/tests/functional/commands/validate/lib/models/s3_multiple_events_same_bucket.yaml +++ b/tests/functional/commands/validate/lib/models/s3_multiple_events_same_bucket.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: ThumbnailFunction: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/s3_multiple_functions.yaml b/tests/functional/commands/validate/lib/models/s3_multiple_functions.yaml index 75c3569758..a987f804dc 100644 --- a/tests/functional/commands/validate/lib/models/s3_multiple_functions.yaml +++ b/tests/functional/commands/validate/lib/models/s3_multiple_functions.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: FunctionOne: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/s3_with_condition.yaml b/tests/functional/commands/validate/lib/models/s3_with_condition.yaml index c15f4dff8b..9ac944ce3e 100644 --- a/tests/functional/commands/validate/lib/models/s3_with_condition.yaml +++ b/tests/functional/commands/validate/lib/models/s3_with_condition.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- Conditions: MyCondition: Fn::Equals: - - yes - - no + - true + - false Resources: ThumbnailFunction: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/s3_with_dependsOn.yaml b/tests/functional/commands/validate/lib/models/s3_with_dependsOn.yaml index 6d41122b49..eabd25a085 100644 --- a/tests/functional/commands/validate/lib/models/s3_with_dependsOn.yaml +++ b/tests/functional/commands/validate/lib/models/s3_with_dependsOn.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: Topic: Type: AWS::SNS::Topic diff --git a/tests/functional/commands/validate/lib/models/self_managed_kafka_with_intrinsics.yaml b/tests/functional/commands/validate/lib/models/self_managed_kafka_with_intrinsics.yaml index 8c13ff6ed5..4d4c4276d6 100644 --- a/tests/functional/commands/validate/lib/models/self_managed_kafka_with_intrinsics.yaml +++ b/tests/functional/commands/validate/lib/models/self_managed_kafka_with_intrinsics.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: BatchSizeValue: Type: Number @@ -5,7 +7,7 @@ Parameters: EnableValue: Type: String - Default: True + Default: true TopicsValue: Type: CommaDelimitedList @@ -22,7 +24,7 @@ Parameters: Resources: KafkaFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/kafka.zip Handler: index.kafka_handler @@ -40,13 +42,13 @@ Resources: BatchSize: Ref: BatchSizeValue SourceAccessConfigurations: - - Type: VPC_SUBNET - URI: subnet:subnet-12345 - - Type: VPC_SECURITY_GROUP - URI: security_group:sg-67890 - - Type: BASIC_AUTH - URI: - Ref: KafkaUserSecret + - Type: VPC_SUBNET + URI: subnet:subnet-12345 + - Type: VPC_SECURITY_GROUP + URI: security_group:sg-67890 + - Type: BASIC_AUTH + URI: + Ref: KafkaUserSecret ConsumerGroupId: Ref: ConsumerGroupValue @@ -56,4 +58,3 @@ Resources: Name: KafkaUserPassword SecretString: Fn::Sub: '{"username":"testBrokerUser","password":"testBrokerPassword"}' - diff --git a/tests/functional/commands/validate/lib/models/simple_table_ref_parameter_intrinsic.yaml b/tests/functional/commands/validate/lib/models/simple_table_ref_parameter_intrinsic.yaml index 55fcfdec87..ae572553bb 100644 --- a/tests/functional/commands/validate/lib/models/simple_table_ref_parameter_intrinsic.yaml +++ b/tests/functional/commands/validate/lib/models/simple_table_ref_parameter_intrinsic.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: ReadCapacity: Type: Number @@ -7,10 +9,10 @@ Parameters: Default: 15 EnableSSE: Type: String # Boolean parameter types not allowed - Default: True + Default: true Resources: MinimalTableRefParamLongForm: - Type: 'AWS::Serverless::SimpleTable' + Type: AWS::Serverless::SimpleTable Properties: ProvisionedThroughput: ReadCapacityUnits: @@ -19,4 +21,4 @@ Resources: Ref: WriteCapacity SSESpecification: SSEEnabled: - Ref: EnableSSE \ No newline at end of file + Ref: EnableSSE diff --git a/tests/functional/commands/validate/lib/models/simple_table_with_extra_tags.yaml b/tests/functional/commands/validate/lib/models/simple_table_with_extra_tags.yaml index d8daa60c04..6a24b02867 100644 --- a/tests/functional/commands/validate/lib/models/simple_table_with_extra_tags.yaml +++ b/tests/functional/commands/validate/lib/models/simple_table_with_extra_tags.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: TagValueParam: Type: String @@ -5,11 +7,11 @@ Parameters: Resources: MinimalTableWithTags: - Type: 'AWS::Serverless::SimpleTable' - Properties: - Tags: - TagKey1: TagValue1 - TagKey2: "" - TagKey3: - Ref: TagValueParam - TagKey4: "123" + Type: AWS::Serverless::SimpleTable + Properties: + Tags: + TagKey1: TagValue1 + TagKey2: '' + TagKey3: + Ref: TagValueParam + TagKey4: '123' diff --git a/tests/functional/commands/validate/lib/models/simple_table_with_table_name.yaml b/tests/functional/commands/validate/lib/models/simple_table_with_table_name.yaml index 8055c0d709..56ae21a34d 100644 --- a/tests/functional/commands/validate/lib/models/simple_table_with_table_name.yaml +++ b/tests/functional/commands/validate/lib/models/simple_table_with_table_name.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: MySimpleTableParameter: Type: String @@ -5,18 +7,18 @@ Parameters: Resources: MinimalTableWithTableName: - Type: 'AWS::Serverless::SimpleTable' + Type: AWS::Serverless::SimpleTable Properties: TableName: MySimpleTable MinimalTableWithRefTableName: - Type: 'AWS::Serverless::SimpleTable' + Type: AWS::Serverless::SimpleTable Properties: TableName: Ref: MySimpleTableParameter MinimalTableWithSubTableName: - Type: 'AWS::Serverless::SimpleTable' + Type: AWS::Serverless::SimpleTable Properties: TableName: - Fn::Sub: "${AWS::StackName}MySimpleTable" \ No newline at end of file + Fn::Sub: ${AWS::StackName}MySimpleTable diff --git a/tests/functional/commands/validate/lib/models/simpletable.yaml b/tests/functional/commands/validate/lib/models/simpletable.yaml index cfa0b39139..b220e1bfba 100644 --- a/tests/functional/commands/validate/lib/models/simpletable.yaml +++ b/tests/functional/commands/validate/lib/models/simpletable.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- Resources: MinimalTable: - Type: 'AWS::Serverless::SimpleTable' + Type: AWS::Serverless::SimpleTable CompleteTable: - Type: 'AWS::Serverless::SimpleTable' + Type: AWS::Serverless::SimpleTable Properties: PrimaryKey: Name: member-number diff --git a/tests/functional/commands/validate/lib/models/simpletable_with_sse.yaml b/tests/functional/commands/validate/lib/models/simpletable_with_sse.yaml index b9c6560e85..dfdd8a9784 100644 --- a/tests/functional/commands/validate/lib/models/simpletable_with_sse.yaml +++ b/tests/functional/commands/validate/lib/models/simpletable_with_sse.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: TableWithSSE: - Type: 'AWS::Serverless::SimpleTable' + Type: AWS::Serverless::SimpleTable Properties: - SSESpecification: - SSEEnabled: true \ No newline at end of file + SSESpecification: + SSEEnabled: true diff --git a/tests/functional/commands/validate/lib/models/sns.yaml b/tests/functional/commands/validate/lib/models/sns.yaml index 510e607869..a52ab60fca 100644 --- a/tests/functional/commands/validate/lib/models/sns.yaml +++ b/tests/functional/commands/validate/lib/models/sns.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: SaveNotificationFunction: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/sns_existing_other_subscription.yaml b/tests/functional/commands/validate/lib/models/sns_existing_other_subscription.yaml index 0555028eb2..3949653e4f 100644 --- a/tests/functional/commands/validate/lib/models/sns_existing_other_subscription.yaml +++ b/tests/functional/commands/validate/lib/models/sns_existing_other_subscription.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: SaveNotificationFunction: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/sns_existing_sqs.yaml b/tests/functional/commands/validate/lib/models/sns_existing_sqs.yaml index bbd2c77f2c..a1357dee32 100644 --- a/tests/functional/commands/validate/lib/models/sns_existing_sqs.yaml +++ b/tests/functional/commands/validate/lib/models/sns_existing_sqs.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: SaveNotificationFunction: Type: AWS::Serverless::Function @@ -18,14 +20,14 @@ Resources: Enabled: true FilterPolicy: store: - - example_corp + - example_corp price_usd: - - numeric: - - ">=" - - 100 + - numeric: + - '>=' + - 100 Notifications: Type: AWS::SNS::Topic Queue: - Type: AWS::SQS::Queue \ No newline at end of file + Type: AWS::SQS::Queue diff --git a/tests/functional/commands/validate/lib/models/sns_intrinsics.yaml b/tests/functional/commands/validate/lib/models/sns_intrinsics.yaml index cdafe672c6..80466769b5 100644 --- a/tests/functional/commands/validate/lib/models/sns_intrinsics.yaml +++ b/tests/functional/commands/validate/lib/models/sns_intrinsics.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: SnsRegion: Type: String @@ -6,8 +8,8 @@ Parameters: Conditions: MyCondition: Fn::Equals: - - true - - false + - true + - false Resources: SaveNotificationFunction: @@ -22,15 +24,15 @@ Resources: Properties: FilterPolicy: Fn::If: - - MyCondition - - price_usd: - - numeric: - - ">=" - - 100 - - price_usd: - - numeric: - - "<" - - 100 + - MyCondition + - price_usd: + - numeric: + - '>=' + - 100 + - price_usd: + - numeric: + - < + - 100 Region: Ref: SnsRegion SqsSubscription: true diff --git a/tests/functional/commands/validate/lib/models/sns_outside_sqs.yaml b/tests/functional/commands/validate/lib/models/sns_outside_sqs.yaml index 08436c1ae5..37c6f64c29 100644 --- a/tests/functional/commands/validate/lib/models/sns_outside_sqs.yaml +++ b/tests/functional/commands/validate/lib/models/sns_outside_sqs.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: SaveNotificationFunction: Type: AWS::Serverless::Function @@ -18,11 +20,11 @@ Resources: Enabled: true FilterPolicy: store: - - example_corp + - example_corp price_usd: - - numeric: - - ">=" - - 100 + - numeric: + - '>=' + - 100 Notifications: Type: AWS::SNS::Topic diff --git a/tests/functional/commands/validate/lib/models/sns_sqs.yaml b/tests/functional/commands/validate/lib/models/sns_sqs.yaml index dad81363e7..d15086dc67 100644 --- a/tests/functional/commands/validate/lib/models/sns_sqs.yaml +++ b/tests/functional/commands/validate/lib/models/sns_sqs.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: SaveNotificationFunction: Type: AWS::Serverless::Function @@ -13,11 +15,11 @@ Resources: SqsSubscription: true FilterPolicy: store: - - example_corp + - example_corp price_usd: - - numeric: - - ">=" - - 100 + - numeric: + - '>=' + - 100 Notifications: Type: AWS::SNS::Topic diff --git a/tests/functional/commands/validate/lib/models/sns_topic_outside_template.yaml b/tests/functional/commands/validate/lib/models/sns_topic_outside_template.yaml index 539a2357fd..ada018f412 100644 --- a/tests/functional/commands/validate/lib/models/sns_topic_outside_template.yaml +++ b/tests/functional/commands/validate/lib/models/sns_topic_outside_template.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Parameters: SNSTopicArn: Type: String diff --git a/tests/functional/commands/validate/lib/models/sqs.yaml b/tests/functional/commands/validate/lib/models/sqs.yaml index 9d45de0a86..8476c90e51 100644 --- a/tests/functional/commands/validate/lib/models/sqs.yaml +++ b/tests/functional/commands/validate/lib/models/sqs.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: SQSFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/queues.zip Handler: queue.sqs_handler diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_api_auth_default_scopes.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_api_auth_default_scopes.yaml index 87cd870300..26ba5a5e53 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_api_auth_default_scopes.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_api_auth_default_scopes.yaml @@ -1,22 +1,24 @@ +%YAML 1.1 +--- Resources: MyApiWithCognitoAuth: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod - OpenApiVersion: "3.0.1" + OpenApiVersion: 3.0.1 Auth: DefaultAuthorizer: MyDefaultCognitoAuth Authorizers: MyDefaultCognitoAuth: UserPoolArn: arn:aws:1 AuthorizationScopes: - - default.write - - default.read + - default.write + - default.read MyCognitoAuthWithDefaultScopes: UserPoolArn: arn:aws:2 AuthorizationScopes: - - default.delete - - default.update + - default.delete + - default.update MyStateMachine: Type: AWS::Serverless::StateMachine @@ -35,11 +37,11 @@ Resources: Result: World End: true Policies: - - Version: "2012-10-17" - Statement: - - Effect: Deny - Action: "*" - Resource: "*" + - Version: '2012-10-17' + Statement: + - Effect: Deny + Action: '*' + Resource: '*' Events: CognitoAuthorizerWithDefaultScopes: Type: Api @@ -72,8 +74,8 @@ Resources: Auth: Authorizer: MyDefaultCognitoAuth AuthorizationScopes: - - overwritten.read - - overwritten.write + - overwritten.read + - overwritten.write CognitoAuthorizerScopesOverwritten: Type: Api Properties: @@ -83,8 +85,8 @@ Resources: Auth: Authorizer: MyCognitoAuthWithDefaultScopes AuthorizationScopes: - - overwritten.read - - overwritten.write + - overwritten.read + - overwritten.write CognitoDefaultScopesNone: Type: Api Properties: diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_api_authorizer.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_api_authorizer.yaml index 1940b0ed0b..79b5ab5dce 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_api_authorizer.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_api_authorizer.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyApi: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -34,11 +36,11 @@ Resources: Result: World End: true Policies: - - Version: "2012-10-17" - Statement: - - Effect: Deny - Action: "*" - Resource: "*" + - Version: '2012-10-17' + Statement: + - Effect: Deny + Action: '*' + Resource: '*' Events: WithNoAuthorizer: Type: Api diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_api_authorizer_maximum.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_api_authorizer_maximum.yaml index 31b235666e..96d3d48f1d 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_api_authorizer_maximum.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_api_authorizer_maximum.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyApi: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod Auth: @@ -15,8 +17,8 @@ Resources: MyCognitoAuthMultipleUserPools: UserPoolArn: - - arn:aws:2 - - arn:aws:3 + - arn:aws:2 + - arn:aws:3 Identity: Header: MyAuthorizationHeader2 ValidationExpression: myauthvalidationexpression2 @@ -42,15 +44,15 @@ Resources: FunctionInvokeRole: arn:aws:iam::123456789012:role/S3Access Identity: Headers: - - Authorization1 + - Authorization1 QueryStrings: - - Authorization2 + - Authorization2 StageVariables: - - Authorization3 + - Authorization3 Context: - - Authorization4 + - Authorization4 ReauthorizeEvery: 0 - + StateMachine: Type: AWS::Serverless::StateMachine Properties: @@ -69,11 +71,11 @@ Resources: Result: World End: true Policies: - - Version: "2012-10-17" - Statement: - - Effect: Deny - Action: "*" - Resource: "*" + - Version: '2012-10-17' + Statement: + - Effect: Deny + Action: '*' + Resource: '*' Events: WithNoAuthorizer: Type: Api @@ -99,7 +101,7 @@ Resources: Method: get Auth: Authorizer: MyLambdaTokenAuth - WithLambdaTokenAuthorizer: + WithLambdaTokenAuthorizerNoneFunctionInvokeRole: Type: Api Properties: RestApiId: !Ref MyApi @@ -120,4 +122,4 @@ Resources: Properties: RestApiId: !Ref MyApi Path: /users - Method: put \ No newline at end of file + Method: put diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_api_resource_policy.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_api_resource_policy.yaml index 8ca0bbed1e..38ec5aa3cb 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_api_resource_policy.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_api_resource_policy.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: ExplicitApi: Type: AWS::Serverless::Api @@ -21,11 +23,11 @@ Resources: Result: World End: true Policies: - - Version: "2012-10-17" - Statement: - - Effect: Deny - Action: "*" - Resource: "*" + - Version: '2012-10-17' + Statement: + - Effect: Deny + Action: '*' + Resource: '*' Events: GetHtml: Type: Api @@ -36,8 +38,8 @@ Resources: Method: get Auth: ResourcePolicy: - IpRangeWhitelist: ["1.2.3.4"] - IpRangeBlacklist: ["1.2.3.4"] + IpRangeWhitelist: [1.2.3.4] + IpRangeBlacklist: [1.2.3.4] PostHtml: Type: Api Properties: @@ -47,8 +49,8 @@ Resources: Method: post Auth: ResourcePolicy: - IpRangeWhitelist: ["1.2.3.4"] - IpRangeBlacklist: ["1.2.3.4"] + IpRangeWhitelist: [1.2.3.4] + IpRangeBlacklist: [1.2.3.4] PutHtml: Type: Api Properties: diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_condition.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_condition.yaml index 58f2227dab..d5b49f51cc 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_condition.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_condition.yaml @@ -1,12 +1,14 @@ +%YAML 1.1 +--- Conditions: TestCondition: Fn::Equals: - - test - - test + - test + - test Resources: StateMachine: Type: AWS::Serverless::StateMachine - Condition: "TestCondition" + Condition: TestCondition Properties: Name: MyStateMachine DefinitionUri: diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_condition_and_events.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_condition_and_events.yaml index 710eb4bd3f..86906ca075 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_condition_and_events.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_condition_and_events.yaml @@ -1,19 +1,21 @@ +%YAML 1.1 +--- Conditions: TestCondition: Fn::Equals: - - test - - test + - test + - test Resources: StateMachine: Type: AWS::Serverless::StateMachine - Condition: "TestCondition" + Condition: TestCondition Properties: Name: MyStateMachine Events: ScheduleEvent: Type: Schedule Properties: - Schedule: "rate(1 minute)" + Schedule: rate(1 minute) Name: TestSchedule CWEvent: Type: CloudWatchEvent @@ -21,7 +23,7 @@ Resources: Pattern: detail: state: - - terminated + - terminated MyApiEvent: Type: Api Properties: diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_cwe.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_cwe.yaml index 488d8dc995..05d1d25165 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_cwe.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_cwe.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: StateMachine: - Type: 'AWS::Serverless::StateMachine' + Type: AWS::Serverless::StateMachine Properties: DefinitionUri: s3://sam-demo-bucket/my_state_machine.asl.json Role: arn:aws:iam::123456123456:role/service-role/SampleRole @@ -8,6 +10,8 @@ Resources: CWEvent: Type: CloudWatchEvent Properties: + RuleName: MyRule + State: ENABLED Pattern: detail: state: diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_definition_S3_object.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_definition_S3_object.yaml index 7a9923f2b2..b4cb79066c 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_definition_S3_object.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_definition_S3_object.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyFunction: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -19,8 +21,8 @@ Resources: DefinitionSubstitutions: my_lambda_arn: !GetAtt MyFunction.Arn Policies: - - Version: "2012-10-17" - Statement: - - Effect: Allow - Action: lambda:InvokeFunction - Resource: !GetAtt MyFunction.Arn + - Version: '2012-10-17' + Statement: + - Effect: Allow + Action: lambda:InvokeFunction + Resource: !GetAtt MyFunction.Arn diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_definition_S3_string.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_definition_S3_string.yaml index c26974b90b..3532420c68 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_definition_S3_string.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_definition_S3_string.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyFunction: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -16,8 +18,8 @@ Resources: DefinitionSubstitutions: my_lambda_arn: !GetAtt MyFunction.Arn Policies: - - Version: "2012-10-17" - Statement: - - Effect: Allow - Action: lambda:InvokeFunction - Resource: !GetAtt MyFunction.Arn + - Version: '2012-10-17' + Statement: + - Effect: Allow + Action: lambda:InvokeFunction + Resource: !GetAtt MyFunction.Arn diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_definition_substitutions.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_definition_substitutions.yaml index 1558eebebb..95f3df1b18 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_definition_substitutions.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_definition_substitutions.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyFunction: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -14,19 +16,19 @@ Resources: StartAt: Hello States: Hello: - Type: "${my_state_var_1}" + Type: ${my_state_var_1} Result: Hello Next: World World: - Type: "${my_state_var_2}" + Type: ${my_state_var_2} Resource: !GetAtt MyFunction.Arn End: true DefinitionSubstitutions: my_state_var_1: Pass my_state_var_2: Task Policies: - - Version: "2012-10-17" - Statement: - - Effect: Allow - Action: lambda:InvokeFunction - Resource: !GetAtt MyFunction.Arn + - Version: '2012-10-17' + Statement: + - Effect: Allow + Action: lambda:InvokeFunction + Resource: !GetAtt MyFunction.Arn diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_eb_dlq.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_eb_dlq.yaml index 90721bd207..24d699a58e 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_eb_dlq.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_eb_dlq.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: StateMachine: - Type: 'AWS::Serverless::StateMachine' + Type: AWS::Serverless::StateMachine Properties: DefinitionUri: s3://sam-demo-bucket/my_state_machine.asl.json Role: arn:aws:iam::123456123456:role/service-role/SampleRole @@ -13,4 +15,4 @@ Resources: state: - terminated DeadLetterConfig: - Arn: TestDlqArn \ No newline at end of file + Arn: TestDlqArn diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_eb_dlq_generated.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_eb_dlq_generated.yaml index 9f8d746770..9636ab416b 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_eb_dlq_generated.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_eb_dlq_generated.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: StateMachine: - Type: 'AWS::Serverless::StateMachine' + Type: AWS::Serverless::StateMachine Properties: DefinitionUri: s3://sam-demo-bucket/my_state_machine.asl.json Role: arn:aws:iam::123456123456:role/service-role/SampleRole @@ -14,4 +16,4 @@ Resources: - terminated DeadLetterConfig: Type: SQS - QueueLogicalId: TestDLQ \ No newline at end of file + QueueLogicalId: TestDLQ diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_eb_retry_policy.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_eb_retry_policy.yaml index 21dc2d921d..4284fe5104 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_eb_retry_policy.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_eb_retry_policy.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: StateMachine: - Type: 'AWS::Serverless::StateMachine' + Type: AWS::Serverless::StateMachine Properties: DefinitionUri: s3://sam-demo-bucket/my_state_machine.asl.json Role: arn:aws:iam::123456123456:role/service-role/SampleRole @@ -14,4 +16,4 @@ Resources: - terminated RetryPolicy: MaximumRetryAttempts: 5 - MaximumEventAgeInSeconds: 300 \ No newline at end of file + MaximumEventAgeInSeconds: 300 diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_event_schedule_state.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_event_schedule_state.yaml index ae5e5b363f..9434753d4b 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_event_schedule_state.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_event_schedule_state.yaml @@ -1,8 +1,10 @@ -Transform: "AWS::Serverless-2016-10-31" +%YAML 1.1 +--- +Transform: AWS::Serverless-2016-10-31 Resources: ScheduledStateMachine: - Type: 'AWS::Serverless::StateMachine' + Type: AWS::Serverless::StateMachine Properties: DefinitionUri: s3://sam-demo-bucket/my_state_machine.asl.json Role: arn:aws:iam::123456123456:role/service-role/SampleRole @@ -10,21 +12,21 @@ Resources: Schedule1: Type: Schedule Properties: - Schedule: 'rate(1 minute)' + Schedule: rate(1 minute) Name: test-schedule Description: Test Schedule - State: "Enabled" + State: Enabled Schedule2: Type: Schedule Properties: - Schedule: 'rate(1 minute)' + Schedule: rate(1 minute) Name: test-schedule Description: Test Schedule State: !Sub "Enabled" Schedule3: Type: Schedule Properties: - Schedule: 'rate(1 minute)' + Schedule: rate(1 minute) Name: test-schedule Description: Test Schedule State: !Ref ScheduleState diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_explicit_api.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_explicit_api.yaml index 6f07fbba08..52fab2e4d7 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_explicit_api.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_explicit_api.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyApi: - Type: "AWS::Serverless::Api" + Type: AWS::Serverless::Api Properties: StageName: Prod @@ -22,11 +24,11 @@ Resources: Result: World End: true Policies: - - Version: "2012-10-17" - Statement: - - Effect: Deny - Action: "*" - Resource: "*" + - Version: '2012-10-17' + Statement: + - Effect: Deny + Action: '*' + Resource: '*' Events: MyApiEvent: Type: Api diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_express_logging.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_express_logging.yaml index 29d253a508..6c68a9f1ec 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_express_logging.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_express_logging.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyFunction: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -22,27 +24,27 @@ Resources: my_lambda_arn: !GetAtt MyFunction.Arn Logging: Level: FATAL - IncludeExecutionData: False + IncludeExecutionData: false Destinations: - - CloudWatchLogsLogGroup: - LogGroupArn: !GetAtt ExpressLogGroup.Arn + - CloudWatchLogsLogGroup: + LogGroupArn: !GetAtt ExpressLogGroup.Arn Policies: - - Version: "2012-10-17" - Statement: - - Effect: Allow - Action: lambda:InvokeFunction - Resource: !GetAtt MyFunction.Arn - - Version: "2012-10-17" - Statement: - - Effect: Allow - Action: - - "logs:CreateLogDelivery" - - "logs:GetLogDelivery" - - "logs:UpdateLogDelivery" - - "logs:DeleteLogDelivery" - - "logs:ListLogDeliveries" - - "logs:PutResourcePolicy" - - "logs:DescribeResourcePolicies" - - "logs:DescribeLogGroups" - Resource: - - "*" + - Version: '2012-10-17' + Statement: + - Effect: Allow + Action: lambda:InvokeFunction + Resource: !GetAtt MyFunction.Arn + - Version: '2012-10-17' + Statement: + - Effect: Allow + Action: + - logs:CreateLogDelivery + - logs:GetLogDelivery + - logs:UpdateLogDelivery + - logs:DeleteLogDelivery + - logs:ListLogDeliveries + - logs:PutResourcePolicy + - logs:DescribeResourcePolicies + - logs:DescribeLogGroups + Resource: + - '*' diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_implicit_api.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_implicit_api.yaml index 3682855625..a232a10486 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_implicit_api.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_implicit_api.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: StateMachine: Type: AWS::Serverless::StateMachine @@ -17,11 +19,11 @@ Resources: Result: World End: true Policies: - - Version: "2012-10-17" - Statement: - - Effect: Deny - Action: "*" - Resource: "*" + - Version: '2012-10-17' + Statement: + - Effect: Deny + Action: '*' + Resource: '*' Events: MyApiEvent: Type: Api diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_implicit_api_globals.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_implicit_api_globals.yaml index 5c1c227c04..b4b8512e45 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_implicit_api_globals.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_implicit_api_globals.yaml @@ -1,8 +1,10 @@ +%YAML 1.1 +--- Globals: Api: Auth: ResourcePolicy: - AwsAccountBlacklist: ["12345"] + AwsAccountBlacklist: ['12345'] Resources: StateMachine: Type: AWS::Serverless::StateMachine @@ -22,11 +24,11 @@ Resources: Result: World End: true Policies: - - Version: "2012-10-17" - Statement: - - Effect: Deny - Action: "*" - Resource: "*" + - Version: '2012-10-17' + Statement: + - Effect: Deny + Action: '*' + Resource: '*' Events: MyApiEvent: Type: Api diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_inline_definition.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_inline_definition.yaml index f77f25a2e0..81f6aae134 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_inline_definition.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_inline_definition.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: StateMachine: Type: AWS::Serverless::StateMachine @@ -17,8 +19,8 @@ Resources: Result: World End: true Policies: - - Version: '2012-10-17' - Statement: - - Effect: Deny - Action: "*" - Resource: "*" + - Version: '2012-10-17' + Statement: + - Effect: Deny + Action: '*' + Resource: '*' diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_inline_definition_intrinsics.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_inline_definition_intrinsics.yaml index 2949605fb0..2b421b2288 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_inline_definition_intrinsics.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_inline_definition_intrinsics.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -25,8 +27,8 @@ Resources: Resource: !GetAtt MyFunction.Arn End: true Policies: - - Version: '2012-10-17' - Statement: - - Effect: Allow - Action: lambda:InvokeFunction - Resource: !GetAtt MyFunction.Arn + - Version: '2012-10-17' + Statement: + - Effect: Allow + Action: lambda:InvokeFunction + Resource: !GetAtt MyFunction.Arn diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_inline_policies.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_inline_policies.yaml index 1d68c6b82d..2b421b2288 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_inline_policies.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_inline_policies.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyFunction: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -25,8 +27,8 @@ Resources: Resource: !GetAtt MyFunction.Arn End: true Policies: - - Version: "2012-10-17" - Statement: - - Effect: Allow - Action: lambda:InvokeFunction - Resource: !GetAtt MyFunction.Arn + - Version: '2012-10-17' + Statement: + - Effect: Allow + Action: lambda:InvokeFunction + Resource: !GetAtt MyFunction.Arn diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_managed_policy.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_managed_policy.yaml index 3479983dcd..34748f53f7 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_managed_policy.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_managed_policy.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: StateMachine: Type: AWS::Serverless::StateMachine @@ -6,4 +8,4 @@ Resources: Type: STANDARD DefinitionUri: s3://sam-demo-bucket/my-state-machine.asl.json Policies: - - AmazonDynamoDBFullAccess + - AmazonDynamoDBFullAccess diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_null_events.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_null_events.yaml index 5c74098c36..7998fcab88 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_null_events.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_null_events.yaml @@ -1,7 +1,9 @@ +%YAML 1.1 +--- Resources: StateMachine: - Type: 'AWS::Serverless::StateMachine' + Type: AWS::Serverless::StateMachine Properties: DefinitionUri: s3://sam-demo-bucket/my_state_machine.asl.json Role: arn:aws:iam::123456123456:role/service-role/SampleRole - Events: \ No newline at end of file + Events: diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_permissions_boundary.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_permissions_boundary.yaml index 5d86d465bb..97a232adf9 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_permissions_boundary.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_permissions_boundary.yaml @@ -1,11 +1,13 @@ +%YAML 1.1 +--- Resources: MyFunction: - Type: AWS::Serverless::Function - Properties: - CodeUri: s3://sam-demo-bucket/hello.zip - Handler: hello.handler - Runtime: python2.7 - ReservedConcurrentExecutions: 100 + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip + Handler: hello.handler + Runtime: python2.7 + ReservedConcurrentExecutions: 100 StateMachine: Type: AWS::Serverless::StateMachine @@ -15,7 +17,7 @@ Resources: ScheduleEvent: Type: Schedule Properties: - Schedule: "rate(1 minute)" + Schedule: rate(1 minute) Name: TestSchedule CWEvent: Type: CloudWatchEvent @@ -23,7 +25,7 @@ Resources: Pattern: detail: state: - - terminated + - terminated MyApiEvent: Type: Api Properties: @@ -35,5 +37,5 @@ Resources: Version: 3 PermissionsBoundary: arn:aws:1234:iam:boundary/CustomerCreatedPermissionsBoundary Policies: - - LambdaInvokePolicy: - FunctionName: !Ref MyFunction \ No newline at end of file + - LambdaInvokePolicy: + FunctionName: !Ref MyFunction diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_role.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_role.yaml index 1d0885f5f0..e1cd40ba5f 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_role.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_role.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: StateMachine: Type: AWS::Serverless::StateMachine diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_sam_policy_templates.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_sam_policy_templates.yaml index a099fc204d..89dbfb08a0 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_sam_policy_templates.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_sam_policy_templates.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: StarterLambda: Type: AWS::Serverless::Function @@ -5,17 +7,17 @@ Resources: CodeUri: s3://sam-demo-bucket/starter.zip Handler: starter.handler Runtime: python2.7 - + ProcessingQueue: Type: AWS::SQS::Queue - + ResolverLambda: Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/resolver.zip Handler: resolver.handler Runtime: python3.8 - + NestedWorkflow: Type: AWS::Serverless::StateMachine Properties: @@ -32,7 +34,7 @@ Resources: NestedStateTwo: Type: Task Resource: !GetAtt StarterLambda.Arn - End: True + End: true Role: arn:aws:iam::123456123456:role/service-role/SampleRole OutputStore: @@ -68,7 +70,7 @@ Resources: Resource: arn:aws:states:::sqs:sendMessage.waitForTaskToken Parameters: QueueUrl: !Ref ProcessingQueue - MessageBody.$: "$.input.message" + MessageBody.$: $.input.message Next: BranchOne_StateThree BranchOne_StateThree: Type: Task @@ -79,10 +81,10 @@ Resources: BranchOne_StateFour: Type: Choice Choices: - - Variable: "$.value" + - Variable: $.value NumericEquals: 0 Next: ValueIsZero - - Variable: "$.value" + - Variable: $.value NumericEquals: 1 Next: ValueIsOne ValueIsZero: @@ -107,20 +109,20 @@ Resources: TableName: !Ref OutputStore Item: MessageId: - S.$: "$.MessageDetails.MessageId" + S.$: $.MessageDetails.MessageId Body: - S.$: "$.MessageDetails.Body" + S.$: $.MessageDetails.Body Next: BranchTwo_StateThree BranchTwo_StateThree: Type: Succeed Policies: - - LambdaInvokePolicy: - FunctionName: !Ref StarterLambda - - SQSSendMessagePolicy: - QueueName: !GetAtt ProcessingQueue.QueueName - - LambdaInvokePolicy: - FunctionName: !Ref ResolverLambda - - StepFunctionsExecutionPolicy: - StateMachineName: !GetAtt NestedWorkflow.Name - - DynamoDBWritePolicy: - TableName: !Ref OutputStore \ No newline at end of file + - LambdaInvokePolicy: + FunctionName: !Ref StarterLambda + - SQSSendMessagePolicy: + QueueName: !GetAtt ProcessingQueue.QueueName + - LambdaInvokePolicy: + FunctionName: !Ref ResolverLambda + - StepFunctionsExecutionPolicy: + StateMachineName: !GetAtt NestedWorkflow.Name + - DynamoDBWritePolicy: + TableName: !Ref OutputStore diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_schedule.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_schedule.yaml index 324ce30f8e..b5608f1658 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_schedule.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_schedule.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: StateMachine: - Type: 'AWS::Serverless::StateMachine' + Type: AWS::Serverless::StateMachine Properties: DefinitionUri: s3://sam-demo-bucket/my_state_machine.asl.json Role: arn:aws:iam::123456123456:role/service-role/SampleRole @@ -8,7 +10,32 @@ Resources: ScheduleEvent: Type: Schedule Properties: - Schedule: 'rate(1 minute)' + Schedule: rate(1 minute) Name: TestSchedule Description: test schedule - Enabled: False \ No newline at end of file + Enabled: false + ScheduleV2: + Type: ScheduleV2 + Properties: + ScheduleExpression: rate(1 minute) + ScheduleV2MoreProperties: + Type: ScheduleV2 + Properties: + ScheduleExpression: rate(1 minute) + Name: test-scheduler + Description: Test Schedule + FlexibleTimeWindow: + Mode: FLEXIBLE + MaximumWindowInMinutes: 5 + State: !Ref ScheduleState + StartDate: '2014-10-02T15:01:23' + EndDate: '2015-10-02T15:01:23' + ScheduleExpressionTimezone: UTC + GroupName: group-name + KmsKeyArn: !Ref KMSKeyArn + PermissionsBoundary: arn:aws:1234:iam:boundary/CustomerCreatedPermissionsBoundaryForSchedule + ScheduleV2WithRole: + Type: ScheduleV2 + Properties: + ScheduleExpression: rate(1 minute) + RoleArn: !Sub 'arn:${AWS::Partition}:iam::role/yoyo' diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_schedule_dlq_retry_policy.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_schedule_dlq_retry_policy.yaml index 9f7385f901..98031f5c90 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_schedule_dlq_retry_policy.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_schedule_dlq_retry_policy.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: StateMachine: - Type: 'AWS::Serverless::StateMachine' + Type: AWS::Serverless::StateMachine Properties: DefinitionUri: s3://sam-demo-bucket/my_state_machine.asl.json Role: arn:aws:iam::123456123456:role/service-role/SampleRole @@ -8,12 +10,23 @@ Resources: ScheduleEvent: Type: Schedule Properties: - Schedule: 'rate(1 minute)' + Schedule: rate(1 minute) Name: TestSchedule Description: test schedule - Enabled: False + Enabled: false DeadLetterConfig: Arn: Arn RetryPolicy: MaximumRetryAttempts: 5 - MaximumEventAgeInSeconds: 300 \ No newline at end of file + MaximumEventAgeInSeconds: 300 + ScheduleEventV2: + Type: ScheduleV2 + Properties: + ScheduleExpression: rate(1 minute) + FlexibleTimeWindow: + Mode: 'OFF' + DeadLetterConfig: + Arn: Arn + RetryPolicy: + MaximumRetryAttempts: 5 + MaximumEventAgeInSeconds: 300 diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_standard_logging.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_standard_logging.yaml index 529a1a1dd3..f2246a498e 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_standard_logging.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_standard_logging.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyFunction: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -22,27 +24,27 @@ Resources: my_lambda_arn: !GetAtt MyFunction.Arn Logging: Level: ALL - IncludeExecutionData: True + IncludeExecutionData: true Destinations: - - CloudWatchLogsLogGroup: - LogGroupArn: !GetAtt StandardLogGroup.Arn + - CloudWatchLogsLogGroup: + LogGroupArn: !GetAtt StandardLogGroup.Arn Policies: - - Version: "2012-10-17" - Statement: - - Effect: Allow - Action: lambda:InvokeFunction - Resource: !GetAtt MyFunction.Arn - - Version: "2012-10-17" - Statement: - - Effect: Allow - Action: - - "logs:CreateLogDelivery" - - "logs:GetLogDelivery" - - "logs:UpdateLogDelivery" - - "logs:DeleteLogDelivery" - - "logs:ListLogDeliveries" - - "logs:PutResourcePolicy" - - "logs:DescribeResourcePolicies" - - "logs:DescribeLogGroups" - Resource: - - "*" + - Version: '2012-10-17' + Statement: + - Effect: Allow + Action: lambda:InvokeFunction + Resource: !GetAtt MyFunction.Arn + - Version: '2012-10-17' + Statement: + - Effect: Allow + Action: + - logs:CreateLogDelivery + - logs:GetLogDelivery + - logs:UpdateLogDelivery + - logs:DeleteLogDelivery + - logs:ListLogDeliveries + - logs:PutResourcePolicy + - logs:DescribeResourcePolicies + - logs:DescribeLogGroups + Resource: + - '*' diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_tags.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_tags.yaml index dd1e15b125..b86b3b1494 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_tags.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_tags.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: StateMachine: Type: AWS::Serverless::StateMachine @@ -17,11 +19,11 @@ Resources: Result: World End: true Policies: - - Version: "2012-10-17" - Statement: - - Effect: Deny - Action: "*" - Resource: "*" + - Version: '2012-10-17' + Statement: + - Effect: Deny + Action: '*' + Resource: '*' Tags: TagOne: ValueOne TagTwo: ValueTwo diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_xray_policies.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_xray_policies.yaml index 719d5874ab..be5b681cdd 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_xray_policies.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_xray_policies.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MyFunction: - Type: "AWS::Serverless::Function" + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -15,8 +17,8 @@ Resources: Tracing: Enabled: true Policies: - - Version: "2012-10-17" - Statement: - - Effect: Allow - Action: lambda:InvokeFunction - Resource: !GetAtt MyFunction.Arn + - Version: '2012-10-17' + Statement: + - Effect: Allow + Action: lambda:InvokeFunction + Resource: !GetAtt MyFunction.Arn diff --git a/tests/functional/commands/validate/lib/models/state_machine_with_xray_role.yaml b/tests/functional/commands/validate/lib/models/state_machine_with_xray_role.yaml index f5e56e7294..3d03acdc43 100644 --- a/tests/functional/commands/validate/lib/models/state_machine_with_xray_role.yaml +++ b/tests/functional/commands/validate/lib/models/state_machine_with_xray_role.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: StateMachine: Type: AWS::Serverless::StateMachine diff --git a/tests/functional/commands/validate/lib/models/streams.yaml b/tests/functional/commands/validate/lib/models/streams.yaml index 3ae736b79b..7420d82719 100644 --- a/tests/functional/commands/validate/lib/models/streams.yaml +++ b/tests/functional/commands/validate/lib/models/streams.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: KinesisFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/streams.zip Handler: stream.kinesis_handler @@ -14,7 +16,7 @@ Resources: StartingPosition: TRIM_HORIZON Enabled: false DynamoDBFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/streams.zip Handler: stream.ddb_handler @@ -27,7 +29,7 @@ Resources: BatchSize: 200 StartingPosition: LATEST MSKFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/streams.zip Handler: stream.msk_handler @@ -39,4 +41,4 @@ Resources: Stream: arn:aws:kafka:us-west-2:012345678901:cluster/mycluster/6cc0432b-8618-4f44-bccc-e1fbd8fb7c4d-2 StartingPosition: LATEST Topics: - - "Topic1" + - Topic1 diff --git a/tests/functional/commands/validate/lib/models/translate_convert_metadata.yaml b/tests/functional/commands/validate/lib/models/translate_convert_metadata.yaml index 0043cba6cf..871539ea0e 100644 --- a/tests/functional/commands/validate/lib/models/translate_convert_metadata.yaml +++ b/tests/functional/commands/validate/lib/models/translate_convert_metadata.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: ThumbnailFunction: Type: AWS::Serverless::Function diff --git a/tests/functional/commands/validate/lib/models/unsupported_resources.yaml b/tests/functional/commands/validate/lib/models/unsupported_resources.yaml index 690b9994e3..f47abc949c 100644 --- a/tests/functional/commands/validate/lib/models/unsupported_resources.yaml +++ b/tests/functional/commands/validate/lib/models/unsupported_resources.yaml @@ -1,3 +1,5 @@ +%YAML 1.1 +--- Resources: # These resources are NOT errors from the eye of translator. # Translator will simply ignore resources with unknown type in order to accept non-SAM resources diff --git a/tests/functional/commands/validate/lib/models/version_deletion_policy_precedence.yaml b/tests/functional/commands/validate/lib/models/version_deletion_policy_precedence.yaml index bf868f9a6e..ca5b1434e7 100644 --- a/tests/functional/commands/validate/lib/models/version_deletion_policy_precedence.yaml +++ b/tests/functional/commands/validate/lib/models/version_deletion_policy_precedence.yaml @@ -1,6 +1,8 @@ +%YAML 1.1 +--- Resources: MinimalFunction: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler @@ -9,11 +11,11 @@ Resources: VersionDescription: sam-testing MinimalFunction2: - Type: 'AWS::Serverless::Function' + Type: AWS::Serverless::Function DeletionPolicy: Delete Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 AutoPublishAlias: live - VersionDescription: sam-testing \ No newline at end of file + VersionDescription: sam-testing