From bbec14649bad0d77fa107a38eb9e8a683b6b4a92 Mon Sep 17 00:00:00 2001 From: Ahmed Date: Wed, 4 Dec 2019 17:01:42 +0000 Subject: [PATCH 1/4] Add missing condition in example template --- examples/2016-10-31/lambda_edge/template.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/2016-10-31/lambda_edge/template.yaml b/examples/2016-10-31/lambda_edge/template.yaml index 25cd68aa0d..1b76e0d788 100644 --- a/examples/2016-10-31/lambda_edge/template.yaml +++ b/examples/2016-10-31/lambda_edge/template.yaml @@ -12,7 +12,8 @@ Parameters: - true - false Default: true - +Conditions: + AliasProvisionedConcurrencyEnabled: !Equals [!Ref EnableAliasProvisionedConcurrency, true] Globals: Function: From 7e713a7f3445e9658618dc02be6e646f0a61a53b Mon Sep 17 00:00:00 2001 From: Ahmed Date: Wed, 4 Dec 2019 17:51:32 +0000 Subject: [PATCH 2/4] Amend readme to have the proper description for implementing ProvisionedConcurrencyConfig with a condition on the parent property --- examples/2016-10-31/lambda_edge/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/2016-10-31/lambda_edge/README.md b/examples/2016-10-31/lambda_edge/README.md index b0f9521932..5938416dbd 100644 --- a/examples/2016-10-31/lambda_edge/README.md +++ b/examples/2016-10-31/lambda_edge/README.md @@ -30,8 +30,10 @@ LambdaEdgeFunctionSample: Timeout: 5 # More info at https://github.com/awslabs/serverless-application-model/blob/master/docs/safe_lambda_deployments.rst AutoPublishAlias: live - ProvisionedConcurrencyConfig: - ProvisionedConcurrentExecutions: !If [AliasProvisionedConcurrencyEnabled, !Ref ProvisionedConcurrency, !Ref 'AWS::NoValue'] + ProvisionedConcurrencyConfig: !If + - AliasProvisionedConcurrencyEnabled + - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency + - !Ref 'AWS::NoValue' ``` We must also create a custom IAM Role which allows `lambda.amazonaws.com` and `edgelambda.amazonaws.com` services to assume the role and execute the function. From a04b787d9564ae56ec5de0ecb86730a213351867 Mon Sep 17 00:00:00 2001 From: Ahmed Date: Wed, 4 Dec 2019 17:52:01 +0000 Subject: [PATCH 3/4] Amend lambda edge template to have the proper if condition for ProvisionedConcurrencyConfig on the parent property --- examples/2016-10-31/lambda_edge/template.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/2016-10-31/lambda_edge/template.yaml b/examples/2016-10-31/lambda_edge/template.yaml index 1b76e0d788..6cd9f02247 100644 --- a/examples/2016-10-31/lambda_edge/template.yaml +++ b/examples/2016-10-31/lambda_edge/template.yaml @@ -17,8 +17,10 @@ Conditions: Globals: Function: - ProvisionedConcurrencyConfig: - ProvisionedConcurrentExecutions: !If [AliasProvisionedConcurrencyEnabled, !Ref ProvisionedConcurrency, !Ref 'AWS::NoValue'] + ProvisionedConcurrencyConfig: !If + - AliasProvisionedConcurrencyEnabled + - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency + - !Ref 'AWS::NoValue' Resources: From 0a4fe9939d0e1e6fc21b687845b02565c216694b Mon Sep 17 00:00:00 2001 From: Ahmed Date: Wed, 4 Dec 2019 17:52:28 +0000 Subject: [PATCH 4/4] Amend fixtures for tests --- ...with_no_alias_provisioned_concurrency.yaml | 6 ++++-- .../function_with_deployment_preference.yaml | 6 ++++-- .../function_with_deployment_preference.json | 20 +++++++++---------- .../function_with_deployment_preference.json | 20 +++++++++---------- .../function_with_deployment_preference.json | 20 +++++++++---------- 5 files changed, 38 insertions(+), 34 deletions(-) diff --git a/tests/translator/input/error_function_with_no_alias_provisioned_concurrency.yaml b/tests/translator/input/error_function_with_no_alias_provisioned_concurrency.yaml index 92f1d07c7e..62d8b9b46a 100644 --- a/tests/translator/input/error_function_with_no_alias_provisioned_concurrency.yaml +++ b/tests/translator/input/error_function_with_no_alias_provisioned_concurrency.yaml @@ -21,5 +21,7 @@ Resources: Runtime: python2.7 DeploymentPreference: Type: Linear10PercentEvery3Minutes - ProvisionedConcurrencyConfig: - ProvisionedConcurrentExecutions: !If [AliasProvisionedConcurrencyEnabled, ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency, !Ref 'AWS::NoValue'] + ProvisionedConcurrencyConfig: !If + - AliasProvisionedConcurrencyEnabled + - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency + - !Ref 'AWS::NoValue' diff --git a/tests/translator/input/function_with_deployment_preference.yaml b/tests/translator/input/function_with_deployment_preference.yaml index c0d4e44c1c..d3d5f47d25 100644 --- a/tests/translator/input/function_with_deployment_preference.yaml +++ b/tests/translator/input/function_with_deployment_preference.yaml @@ -22,5 +22,7 @@ Resources: AutoPublishAlias: live DeploymentPreference: Type: Linear10PercentEvery3Minutes - ProvisionedConcurrencyConfig: - ProvisionedConcurrentExecutions: !If [AliasProvisionedConcurrencyEnabled, !Ref ProvisionedConcurrency, !Ref 'AWS::NoValue'] + ProvisionedConcurrencyConfig: !If + - AliasProvisionedConcurrencyEnabled + - ProvisionedConcurrentExecutions: !Ref ProvisionedConcurrency + - !Ref 'AWS::NoValue' diff --git a/tests/translator/output/aws-cn/function_with_deployment_preference.json b/tests/translator/output/aws-cn/function_with_deployment_preference.json index 6fc0718462..830ecaa182 100644 --- a/tests/translator/output/aws-cn/function_with_deployment_preference.json +++ b/tests/translator/output/aws-cn/function_with_deployment_preference.json @@ -174,18 +174,18 @@ ] }, "ProvisionedConcurrencyConfig": { - "ProvisionedConcurrentExecutions": { - "Fn::If": [ - "AliasProvisionedConcurrencyEnabled", - { + "Fn::If": [ + "AliasProvisionedConcurrencyEnabled", + { + "ProvisionedConcurrentExecutions": { "Ref": "ProvisionedConcurrency" - }, - { - "Ref": "AWS::NoValue" } - ] - } - }, + }, + { + "Ref": "AWS::NoValue" + } + ] + }, "FunctionName": { "Ref": "MinimalFunction" } diff --git a/tests/translator/output/aws-us-gov/function_with_deployment_preference.json b/tests/translator/output/aws-us-gov/function_with_deployment_preference.json index 6815a90e2d..3b6868a1ed 100644 --- a/tests/translator/output/aws-us-gov/function_with_deployment_preference.json +++ b/tests/translator/output/aws-us-gov/function_with_deployment_preference.json @@ -174,18 +174,18 @@ ] }, "ProvisionedConcurrencyConfig": { - "ProvisionedConcurrentExecutions": { - "Fn::If": [ - "AliasProvisionedConcurrencyEnabled", - { + "Fn::If": [ + "AliasProvisionedConcurrencyEnabled", + { + "ProvisionedConcurrentExecutions": { "Ref": "ProvisionedConcurrency" - }, - { - "Ref": "AWS::NoValue" } - ] - } - }, + }, + { + "Ref": "AWS::NoValue" + } + ] + }, "FunctionName": { "Ref": "MinimalFunction" } diff --git a/tests/translator/output/function_with_deployment_preference.json b/tests/translator/output/function_with_deployment_preference.json index 2f3de9f66b..e428000afa 100644 --- a/tests/translator/output/function_with_deployment_preference.json +++ b/tests/translator/output/function_with_deployment_preference.json @@ -174,18 +174,18 @@ ] }, "ProvisionedConcurrencyConfig": { - "ProvisionedConcurrentExecutions": { - "Fn::If": [ - "AliasProvisionedConcurrencyEnabled", - { + "Fn::If": [ + "AliasProvisionedConcurrencyEnabled", + { + "ProvisionedConcurrentExecutions": { "Ref": "ProvisionedConcurrency" - }, - { - "Ref": "AWS::NoValue" } - ] - } - }, + }, + { + "Ref": "AWS::NoValue" + } + ] + }, "FunctionName": { "Ref": "MinimalFunction" }