From b824ce4dd923b26efb86d69f69dd0412144ca07d Mon Sep 17 00:00:00 2001 From: connorrobertson Date: Thu, 27 Jul 2023 16:15:18 -0700 Subject: [PATCH 1/7] chore: update schema --- samtranslator/internal/schema_source/sam-docs.json | 4 ++-- samtranslator/schema/schema.json | 4 ++-- schema_source/sam.schema.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/samtranslator/internal/schema_source/sam-docs.json b/samtranslator/internal/schema_source/sam-docs.json index 26dbfc166..44e36cb32 100644 --- a/samtranslator/internal/schema_source/sam-docs.json +++ b/samtranslator/internal/schema_source/sam-docs.json @@ -208,9 +208,9 @@ "EventBusName": "The event bus to associate with this rule\\. If you omit this property, AWS SAM uses the default event bus\\. \n*Type*: String \n*Required*: No \n*Default*: Default event bus \n*AWS CloudFormation compatibility*: This property is passed directly to the [`EventBusName`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventbusname) property of an `AWS::Events::Rule` resource\\.", "Input": "Valid JSON text passed to the target\\. If you use this property, nothing from the event text itself is passed to the target\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Input`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-input) property of an `AWS::Events::Rule Target` resource\\.", "InputPath": "When you don't want to pass the entire matched event to the target, use the `InputPath` property to describe which part of the event to pass\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`InputPath`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputpath) property of an `AWS::Events::Rule Target` resource\\.", - "Name": "The name of the rule\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Name`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-name) property of an `AWS::Events::Rule` resource\\.", "Pattern": "Describes which events are routed to the specified target\\. For more information, see [Amazon EventBridge events](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-events.html) and [EventBridge event patterns](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html) in the *Amazon EventBridge User Guide*\\. \n*Type*: [EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern) \n*Required*: Yes \n*AWS CloudFormation compatibility*: This property is passed directly to the [`EventPattern`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern) property of an `AWS::Events::Rule` resource\\.", "RetryPolicy": "A `RetryPolicy` object that includes information about the retry policy settings\\. For more information, see [Event retry policy and using dead\\-letter queues](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html) in the *Amazon EventBridge User Guide*\\. \n*Type*: [RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`RetryPolicy`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy) property of the `AWS::Events::Rule` `Target` data type\\.", + "RuleName": "The name of the rule\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Name`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-name) property of an `AWS::Events::Rule` resource\\.", "State": "The state of the rule\\. \n*Accepted values*: `DISABLED | ENABLED` \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the `[State](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-state) ` property of an `AWS::Events::Rule` resource\\.", "Target": "The AWS resource that EventBridge invokes when a rule is triggered\\. You can use this property to specify the logical ID of the target\\. If this property is not specified, then AWS SAM generates the logical ID of the target\\. \n*Type*: [Target](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-target.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is similar to the [`Targets`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-targets) property of an `AWS::Events::Rule` resource\\. The AWS SAM version of this property only allows you to specify the logical ID of a single target\\." }, @@ -685,7 +685,7 @@ "AutoPublishAliasAllProperties": "Specifies when a new [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-version.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-version.html) is created\\. When `true`, a new Lambda version is created when any property in the Lambda function is modified\\. When `false`, a new Lambda version is created only when any of the following properties are modified: \n+ `Environment`, `MemorySize`, or `SnapStart`\\.\n+ Any change that results in an update to the `Code` property, such as `CodeDict`, `ImageUri`, or `InlineCode`\\.\nThis property requires `AutoPublishAlias` to be defined\\. \nIf `AutoPublishSha256` is also specified, its behavior takes precedence over `AutoPublishAliasAllProperties: true`\\. \n*Type*: Boolean \n*Required*: No \n*Default value*: `false` \n*AWS CloudFormation compatibility*: This property is unique to AWS SAM and doesn't have an AWS CloudFormation equivalent\\.", "AutoPublishCodeSha256": "The string value that is used, along with the value in `CodeUri`, to determine whether a new Lambda version should be published\\. This property is only used when `AutoPublishAlias` is also defined\\. \nThis property addresses a problem that occurs when an AWS SAM template has the following characteristics: the `DeploymentPreference` object is configured for gradual deployments \\(as described in [Deploying serverless applications gradually](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/automating-updates-to-serverless-apps.html)\\), the `AutoPublishAlias` property is set and doesn't change between deployments, and the `CodeUri` property is set and doesn't change between deployments\\. \nThis scenario can occur when the deployment package stored in an Amazon Simple Storage Service \\(Amazon S3\\) location is replaced by a new deployment package that contains updated Lambda function code, but the `CodeUri` property remains unchanged \\(as opposed to the new deployment package being uploaded to a new Amazon S3 location and the `CodeUri` being changed to the new location\\)\\. \nIn this scenario, to trigger the gradual deployment successfully, you must provide a unique value for `AutoPublishCodeSha256`\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is unique to AWS SAM and doesn't have an AWS CloudFormation equivalent\\.", "CodeSigningConfigArn": "The ARN of the [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-codesigningconfig.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-codesigningconfig.html) resource, used to enable code signing for this function\\. For more information about code signing, see [Configuring code signing for AWS SAM applications](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/authoring-codesigning.html)\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`CodeSigningConfigArn`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-codesigningconfigarn) property of an `AWS::Lambda::Function` resource\\.", - "CodeUri": "The function code's Amazon S3 URI, path to local folder, or [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object\\. This property only applies if the `PackageType` property is set to `Zip`, otherwise it is ignored\\. \n**Notes**: \n1\\. If the `PackageType` property is set to `Zip` \\(default\\), then one of `CodeUri` or `InlineCode` is required\\. \n2\\. If an Amazon S3 URI or [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object is provided, the Amazon S3 object referenced must be a valid [Lambda deployment package](https://docs.aws.amazon.com/lambda/latest/dg/deployment-package-v2.html)\\. \n3\\. If the path to a local folder is provided, for the code to be transformed properly the template must go through the workflow that includes [sam build](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-build.html) followed by either [sam deploy](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-deploy.html) or [sam package](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-package.html)\\. By default, relative paths are resolved with respect to the AWS SAM template's location\\. \n*Type*: String \\| [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) \n*Required*: Conditional \n*AWS CloudFormation compatibility*: This property is similar to the [`Code`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-code) property of an `AWS::Lambda::Function` resource\\. The nested Amazon S3 properties are named differently\\.", + "CodeUri": "The code for the function\\. Accepted values include: \n+ The function's Amazon S3 URI\\. For example, `s3://bucket-123456789/sam-app/1234567890abcdefg`\\.\n+ The local path to the function\\. For example, `hello_world/`\\.\n+ A [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object\\.\nIf you provide a function's Amazon S3 URI or [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object, you must reference a valid [Lambda deployment package](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html)\\. \nIf you provide a local file path, use the AWS SAM CLI to upload the local file at deployment\\. To learn more, see [Using the AWS SAM CLI to upload local files at deployment](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/deploy-upload-local-files.html)\\. \n*Type*: \\[ String \\| [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) \\] \n*Required*: Conditional\\. When `PackageType` is set to `Zip`, one of `CodeUri` or `InlineCode` is required\\. \n*AWS CloudFormation compatibility*: This property is similar to the `[ Code](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-code)` property of an `AWS::Lambda::Function` resource\\. The nested Amazon S3 properties are named differently\\.", "DeadLetterQueue": "Configures an Amazon Simple Notification Service \\(Amazon SNS\\) topic or Amazon Simple Queue Service \\(Amazon SQS\\) queue where Lambda sends events that it can't process\\. For more information about dead\\-letter queue functionality, see [AWS Lambda function dead letter queues](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#dlq) in the *AWS Lambda Developer Guide*\\. \nIf your Lambda function's event source is an Amazon SQS queue, configure a dead\\-letter queue for the source queue, not for the Lambda function\\. The dead\\-letter queue that you configure for a function is used for the function's [asynchronous invocation queue](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html), not for event source queues\\.\n*Type*: Map \\| [DeadLetterQueue](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-deadletterqueue.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is similar to the [`DeadLetterConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-deadletterconfig.html) property of an `AWS::Lambda::Function` resource\\. In AWS CloudFormation the type is derived from the `TargetArn`, whereas in AWS SAM you must pass the type along with the `TargetArn`\\.", "DeploymentPreference": "The settings to enable gradual Lambda deployments\\. \nIf a `DeploymentPreference` object is specified, AWS SAM creates an [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-application.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-application.html) called `ServerlessDeploymentApplication` \\(one per stack\\), an [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-deploymentgroup.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-deploymentgroup.html) called `DeploymentGroup`, and an [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html) called `CodeDeployServiceRole`\\. \n*Type*: [DeploymentPreference](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-deploymentpreference.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is unique to AWS SAM and doesn't have an AWS CloudFormation equivalent\\. \n*See also*: For more information about this property, see [Deploying serverless applications gradually](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/automating-updates-to-serverless-apps.html)\\.", "Description": "A description of the function\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Description`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-description) property of an `AWS::Lambda::Function` resource\\.", diff --git a/samtranslator/schema/schema.json b/samtranslator/schema/schema.json index 852d9f28d..9b5844674 100644 --- a/samtranslator/schema/schema.json +++ b/samtranslator/schema/schema.json @@ -246944,7 +246944,7 @@ "$ref": "#/definitions/CodeUri" } ], - "markdownDescription": "The function code's Amazon S3 URI, path to local folder, or [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object\\. This property only applies if the `PackageType` property is set to `Zip`, otherwise it is ignored\\. \n**Notes**: \n1\\. If the `PackageType` property is set to `Zip` \\(default\\), then one of `CodeUri` or `InlineCode` is required\\. \n2\\. If an Amazon S3 URI or [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object is provided, the Amazon S3 object referenced must be a valid [Lambda deployment package](https://docs.aws.amazon.com/lambda/latest/dg/deployment-package-v2.html)\\. \n3\\. If the path to a local folder is provided, for the code to be transformed properly the template must go through the workflow that includes [sam build](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-build.html) followed by either [sam deploy](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-deploy.html) or [sam package](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-package.html)\\. By default, relative paths are resolved with respect to the AWS SAM template's location\\. \n*Type*: String \\| [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) \n*Required*: Conditional \n*AWS CloudFormation compatibility*: This property is similar to the [`Code`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-code) property of an `AWS::Lambda::Function` resource\\. The nested Amazon S3 properties are named differently\\.", + "markdownDescription": "The code for the function\\. Accepted values include: \n+ The function's Amazon S3 URI\\. For example, `s3://bucket-123456789/sam-app/1234567890abcdefg`\\.\n+ The local path to the function\\. For example, `hello_world/`\\.\n+ A [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object\\.\nIf you provide a function's Amazon S3 URI or [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object, you must reference a valid [Lambda deployment package](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html)\\. \nIf you provide a local file path, use the AWS SAM CLI to upload the local file at deployment\\. To learn more, see [Using the AWS SAM CLI to upload local files at deployment](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/deploy-upload-local-files.html)\\. \n*Type*: \\[ String \\| [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) \\] \n*Required*: Conditional\\. When `PackageType` is set to `Zip`, one of `CodeUri` or `InlineCode` is required\\. \n*AWS CloudFormation compatibility*: This property is similar to the `[ Code](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-code)` property of an `AWS::Lambda::Function` resource\\. The nested Amazon S3 properties are named differently\\.", "title": "CodeUri" }, "DeadLetterQueue": { @@ -247186,7 +247186,7 @@ "$ref": "#/definitions/CodeUri" } ], - "markdownDescription": "The function code's Amazon S3 URI, path to local folder, or [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object\\. This property only applies if the `PackageType` property is set to `Zip`, otherwise it is ignored\\. \n**Notes**: \n1\\. If the `PackageType` property is set to `Zip` \\(default\\), then one of `CodeUri` or `InlineCode` is required\\. \n2\\. If an Amazon S3 URI or [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object is provided, the Amazon S3 object referenced must be a valid [Lambda deployment package](https://docs.aws.amazon.com/lambda/latest/dg/deployment-package-v2.html)\\. \n3\\. If the path to a local folder is provided, for the code to be transformed properly the template must go through the workflow that includes [sam build](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-build.html) followed by either [sam deploy](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-deploy.html) or [sam package](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-package.html)\\. By default, relative paths are resolved with respect to the AWS SAM template's location\\. \n*Type*: String \\| [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) \n*Required*: Conditional \n*AWS CloudFormation compatibility*: This property is similar to the [`Code`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-code) property of an `AWS::Lambda::Function` resource\\. The nested Amazon S3 properties are named differently\\.", + "markdownDescription": "The code for the function\\. Accepted values include: \n+ The function's Amazon S3 URI\\. For example, `s3://bucket-123456789/sam-app/1234567890abcdefg`\\.\n+ The local path to the function\\. For example, `hello_world/`\\.\n+ A [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object\\.\nIf you provide a function's Amazon S3 URI or [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object, you must reference a valid [Lambda deployment package](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html)\\. \nIf you provide a local file path, use the AWS SAM CLI to upload the local file at deployment\\. To learn more, see [Using the AWS SAM CLI to upload local files at deployment](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/deploy-upload-local-files.html)\\. \n*Type*: \\[ String \\| [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) \\] \n*Required*: Conditional\\. When `PackageType` is set to `Zip`, one of `CodeUri` or `InlineCode` is required\\. \n*AWS CloudFormation compatibility*: This property is similar to the `[ Code](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-code)` property of an `AWS::Lambda::Function` resource\\. The nested Amazon S3 properties are named differently\\.", "title": "CodeUri" }, "DeadLetterQueue": { diff --git a/schema_source/sam.schema.json b/schema_source/sam.schema.json index 68ca79b73..33afd8ca9 100644 --- a/schema_source/sam.schema.json +++ b/schema_source/sam.schema.json @@ -5187,7 +5187,7 @@ "$ref": "#/definitions/CodeUri" } ], - "markdownDescription": "The function code's Amazon S3 URI, path to local folder, or [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object\\. This property only applies if the `PackageType` property is set to `Zip`, otherwise it is ignored\\. \n**Notes**: \n1\\. If the `PackageType` property is set to `Zip` \\(default\\), then one of `CodeUri` or `InlineCode` is required\\. \n2\\. If an Amazon S3 URI or [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object is provided, the Amazon S3 object referenced must be a valid [Lambda deployment package](https://docs.aws.amazon.com/lambda/latest/dg/deployment-package-v2.html)\\. \n3\\. If the path to a local folder is provided, for the code to be transformed properly the template must go through the workflow that includes [sam build](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-build.html) followed by either [sam deploy](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-deploy.html) or [sam package](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-package.html)\\. By default, relative paths are resolved with respect to the AWS SAM template's location\\. \n*Type*: String \\| [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) \n*Required*: Conditional \n*AWS CloudFormation compatibility*: This property is similar to the [`Code`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-code) property of an `AWS::Lambda::Function` resource\\. The nested Amazon S3 properties are named differently\\.", + "markdownDescription": "The code for the function\\. Accepted values include: \n+ The function's Amazon S3 URI\\. For example, `s3://bucket-123456789/sam-app/1234567890abcdefg`\\.\n+ The local path to the function\\. For example, `hello_world/`\\.\n+ A [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object\\.\nIf you provide a function's Amazon S3 URI or [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object, you must reference a valid [Lambda deployment package](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html)\\. \nIf you provide a local file path, use the AWS SAM CLI to upload the local file at deployment\\. To learn more, see [Using the AWS SAM CLI to upload local files at deployment](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/deploy-upload-local-files.html)\\. \n*Type*: \\[ String \\| [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) \\] \n*Required*: Conditional\\. When `PackageType` is set to `Zip`, one of `CodeUri` or `InlineCode` is required\\. \n*AWS CloudFormation compatibility*: This property is similar to the `[ Code](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-code)` property of an `AWS::Lambda::Function` resource\\. The nested Amazon S3 properties are named differently\\.", "title": "CodeUri" }, "DeadLetterQueue": { @@ -5541,7 +5541,7 @@ "$ref": "#/definitions/CodeUri" } ], - "markdownDescription": "The function code's Amazon S3 URI, path to local folder, or [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object\\. This property only applies if the `PackageType` property is set to `Zip`, otherwise it is ignored\\. \n**Notes**: \n1\\. If the `PackageType` property is set to `Zip` \\(default\\), then one of `CodeUri` or `InlineCode` is required\\. \n2\\. If an Amazon S3 URI or [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object is provided, the Amazon S3 object referenced must be a valid [Lambda deployment package](https://docs.aws.amazon.com/lambda/latest/dg/deployment-package-v2.html)\\. \n3\\. If the path to a local folder is provided, for the code to be transformed properly the template must go through the workflow that includes [sam build](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-build.html) followed by either [sam deploy](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-deploy.html) or [sam package](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-package.html)\\. By default, relative paths are resolved with respect to the AWS SAM template's location\\. \n*Type*: String \\| [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) \n*Required*: Conditional \n*AWS CloudFormation compatibility*: This property is similar to the [`Code`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-code) property of an `AWS::Lambda::Function` resource\\. The nested Amazon S3 properties are named differently\\.", + "markdownDescription": "The code for the function\\. Accepted values include: \n+ The function's Amazon S3 URI\\. For example, `s3://bucket-123456789/sam-app/1234567890abcdefg`\\.\n+ The local path to the function\\. For example, `hello_world/`\\.\n+ A [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object\\.\nIf you provide a function's Amazon S3 URI or [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) object, you must reference a valid [Lambda deployment package](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html)\\. \nIf you provide a local file path, use the AWS SAM CLI to upload the local file at deployment\\. To learn more, see [Using the AWS SAM CLI to upload local files at deployment](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/deploy-upload-local-files.html)\\. \n*Type*: \\[ String \\| [FunctionCode](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-functioncode.html) \\] \n*Required*: Conditional\\. When `PackageType` is set to `Zip`, one of `CodeUri` or `InlineCode` is required\\. \n*AWS CloudFormation compatibility*: This property is similar to the `[ Code](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-code)` property of an `AWS::Lambda::Function` resource\\. The nested Amazon S3 properties are named differently\\.", "title": "CodeUri" }, "DeadLetterQueue": { From a34a4b7814b9af6328094e731df192cd1eadd9ef Mon Sep 17 00:00:00 2001 From: connorrobertson Date: Mon, 31 Jul 2023 16:48:36 -0700 Subject: [PATCH 2/7] Input Transform for ServerlessFunction --- .../internal/schema_source/aws_serverless_function.py | 1 + samtranslator/internal/schema_source/sam-docs.json | 3 ++- samtranslator/model/eventsources/push.py | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/samtranslator/internal/schema_source/aws_serverless_function.py b/samtranslator/internal/schema_source/aws_serverless_function.py index 23428a0cb..69610babb 100644 --- a/samtranslator/internal/schema_source/aws_serverless_function.py +++ b/samtranslator/internal/schema_source/aws_serverless_function.py @@ -333,6 +333,7 @@ class EventBridgeRuleEventProperties(BaseModel): Pattern: PassThroughProp = eventbridgeruleeventproperties("Pattern") RetryPolicy: Optional[PassThroughProp] = eventbridgeruleeventproperties("RetryPolicy") Target: Optional[EventBridgeRuleTarget] = eventbridgeruleeventproperties("Target") + InputTransformer: Optional[PassThroughProp] = eventbridgeruleeventproperties("InputTransformer") class EventBridgeRuleEvent(BaseModel): diff --git a/samtranslator/internal/schema_source/sam-docs.json b/samtranslator/internal/schema_source/sam-docs.json index 44e36cb32..4d38288aa 100644 --- a/samtranslator/internal/schema_source/sam-docs.json +++ b/samtranslator/internal/schema_source/sam-docs.json @@ -212,7 +212,8 @@ "RetryPolicy": "A `RetryPolicy` object that includes information about the retry policy settings\\. For more information, see [Event retry policy and using dead\\-letter queues](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html) in the *Amazon EventBridge User Guide*\\. \n*Type*: [RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`RetryPolicy`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy) property of the `AWS::Events::Rule` `Target` data type\\.", "RuleName": "The name of the rule\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Name`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-name) property of an `AWS::Events::Rule` resource\\.", "State": "The state of the rule\\. \n*Accepted values*: `DISABLED | ENABLED` \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the `[State](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-state) ` property of an `AWS::Events::Rule` resource\\.", - "Target": "The AWS resource that EventBridge invokes when a rule is triggered\\. You can use this property to specify the logical ID of the target\\. If this property is not specified, then AWS SAM generates the logical ID of the target\\. \n*Type*: [Target](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-target.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is similar to the [`Targets`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-targets) property of an `AWS::Events::Rule` resource\\. The AWS SAM version of this property only allows you to specify the logical ID of a single target\\." + "Target": "The AWS resource that EventBridge invokes when a rule is triggered\\. You can use this property to specify the logical ID of the target\\. If this property is not specified, then AWS SAM generates the logical ID of the target\\. \n*Type*: [Target](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-target.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is similar to the [`Targets`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-targets) property of an `AWS::Events::Rule` resource\\. The AWS SAM version of this property only allows you to specify the logical ID of a single target\\.", + "InputTransformer": "" }, "sam-property-function-eventinvokeconfiguration": { "DestinationConfig": "A configuration object that specifies the destination of an event after Lambda processes it\\. \n*Type*: [EventInvokeDestinationConfiguration](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-eventinvokedestinationconfiguration.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is similar to the [`DestinationConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventinvokeconfig-destinationconfig.html) property of an `AWS::Lambda::EventInvokeConfig` resource\\. SAM requires an extra parameter, \"Type\", that does not exist in CloudFormation\\.", diff --git a/samtranslator/model/eventsources/push.py b/samtranslator/model/eventsources/push.py index b7a51dc16..b140ce315 100644 --- a/samtranslator/model/eventsources/push.py +++ b/samtranslator/model/eventsources/push.py @@ -207,6 +207,7 @@ class CloudWatchEvent(PushEventSource): "Target": PropertyType(False, IS_DICT), "Enabled": PropertyType(False, IS_BOOL), "State": PropertyType(False, IS_STR), + "InputTransformer": PropertyType(False, IS_DICT) } EventBusName: Optional[PassThrough] @@ -219,6 +220,7 @@ class CloudWatchEvent(PushEventSource): Target: Optional[PassThrough] Enabled: Optional[bool] State: Optional[PassThrough] + InputTransformer: Optional[PassThrough] @cw_timer(prefix=FUNCTION_EVETSOURCE_METRIC_PREFIX) def to_cloudformation(self, **kwargs): # type: ignore[no-untyped-def] @@ -291,6 +293,9 @@ def _construct_target(self, function, dead_letter_queue_arn=None): # type: igno if self.RetryPolicy is not None: target["RetryPolicy"] = self.RetryPolicy + if self.InputTransformer is not None: + target["InputTransformer"] = self.InputTransformer + return target From d2beca3101f67fd1b129d1aa81e73aba55f3da8a Mon Sep 17 00:00:00 2001 From: connorrobertson Date: Mon, 31 Jul 2023 16:50:12 -0700 Subject: [PATCH 3/7] make format --- samtranslator/model/eventsources/push.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samtranslator/model/eventsources/push.py b/samtranslator/model/eventsources/push.py index b140ce315..3017b6701 100644 --- a/samtranslator/model/eventsources/push.py +++ b/samtranslator/model/eventsources/push.py @@ -207,7 +207,7 @@ class CloudWatchEvent(PushEventSource): "Target": PropertyType(False, IS_DICT), "Enabled": PropertyType(False, IS_BOOL), "State": PropertyType(False, IS_STR), - "InputTransformer": PropertyType(False, IS_DICT) + "InputTransformer": PropertyType(False, IS_DICT), } EventBusName: Optional[PassThrough] From 6422f5f9007da4fee6187b48b426307df6f6ca42 Mon Sep 17 00:00:00 2001 From: connorrobertson Date: Tue, 1 Aug 2023 10:25:01 -0700 Subject: [PATCH 4/7] Transform tests --- ...ventbridgerule_with_input_transformer.yaml | 39 ++++ ...ventbridgerule_with_input_transformer.json | 192 ++++++++++++++++++ ...ventbridgerule_with_input_transformer.json | 192 ++++++++++++++++++ ...ventbridgerule_with_input_transformer.json | 192 ++++++++++++++++++ 4 files changed, 615 insertions(+) create mode 100644 tests/translator/input/eventbridgerule_with_input_transformer.yaml create mode 100644 tests/translator/output/aws-cn/eventbridgerule_with_input_transformer.json create mode 100644 tests/translator/output/aws-us-gov/eventbridgerule_with_input_transformer.json create mode 100644 tests/translator/output/eventbridgerule_with_input_transformer.json diff --git a/tests/translator/input/eventbridgerule_with_input_transformer.yaml b/tests/translator/input/eventbridgerule_with_input_transformer.yaml new file mode 100644 index 000000000..8b3d9f27a --- /dev/null +++ b/tests/translator/input/eventbridgerule_with_input_transformer.yaml @@ -0,0 +1,39 @@ +Resources: + ScheduledFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO + Handler: hello.handler + Runtime: python2.7 + Events: + Schedule: + Type: Schedule + Properties: + Schedule: rate(1 minute) + TriggeredFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO + Handler: hello.handler + Runtime: python2.7 + Events: + OnTerminate: + Type: EventBridgeRule + Properties: + EventBusName: ExternalEventBridge + Pattern: + detail: + state: + - terminated + Target: + Id: hello345 + InputTransformer: + InputPathsMap: + instance: $.detail.instance-id + state: $.detail.state + InputTemplate: | + { + "instance" : , + "state" : , + "instanceStatus": "instance \"\" is in " + } diff --git a/tests/translator/output/aws-cn/eventbridgerule_with_input_transformer.json b/tests/translator/output/aws-cn/eventbridgerule_with_input_transformer.json new file mode 100644 index 000000000..c0344cb77 --- /dev/null +++ b/tests/translator/output/aws-cn/eventbridgerule_with_input_transformer.json @@ -0,0 +1,192 @@ +{ + "Resources": { + "ScheduledFunction": { + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip", + "S3ObjectVersion": "3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": [ + "ScheduledFunctionRole", + "Arn" + ] + }, + "Runtime": "python2.7", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::Lambda::Function" + }, + "ScheduledFunctionRole": { + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::IAM::Role" + }, + "ScheduledFunctionSchedule": { + "Properties": { + "ScheduleExpression": "rate(1 minute)", + "Targets": [ + { + "Arn": { + "Fn::GetAtt": [ + "ScheduledFunction", + "Arn" + ] + }, + "Id": "ScheduledFunctionScheduleLambdaTarget" + } + ] + }, + "Type": "AWS::Events::Rule" + }, + "ScheduledFunctionSchedulePermission": { + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Ref": "ScheduledFunction" + }, + "Principal": "events.amazonaws.com", + "SourceArn": { + "Fn::GetAtt": [ + "ScheduledFunctionSchedule", + "Arn" + ] + } + }, + "Type": "AWS::Lambda::Permission" + }, + "TriggeredFunction": { + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip", + "S3ObjectVersion": "3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": [ + "TriggeredFunctionRole", + "Arn" + ] + }, + "Runtime": "python2.7", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::Lambda::Function" + }, + "TriggeredFunctionOnTerminate": { + "Properties": { + "EventBusName": "ExternalEventBridge", + "EventPattern": { + "detail": { + "state": [ + "terminated" + ] + } + }, + "Targets": [ + { + "Arn": { + "Fn::GetAtt": [ + "TriggeredFunction", + "Arn" + ] + }, + "Id": "hello345", + "InputTransformer": { + "InputPathsMap": { + "instance": "$.detail.instance-id", + "state": "$.detail.state" + }, + "InputTemplate": "{\n\"instance\" : ,\n\"state\" : ,\n\"instanceStatus\": \"instance \\\"\\\" is in \"\n}\n" + } + } + ] + }, + "Type": "AWS::Events::Rule" + }, + "TriggeredFunctionOnTerminatePermission": { + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Ref": "TriggeredFunction" + }, + "Principal": "events.amazonaws.com", + "SourceArn": { + "Fn::GetAtt": [ + "TriggeredFunctionOnTerminate", + "Arn" + ] + } + }, + "Type": "AWS::Lambda::Permission" + }, + "TriggeredFunctionRole": { + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::IAM::Role" + } + } +} diff --git a/tests/translator/output/aws-us-gov/eventbridgerule_with_input_transformer.json b/tests/translator/output/aws-us-gov/eventbridgerule_with_input_transformer.json new file mode 100644 index 000000000..266096084 --- /dev/null +++ b/tests/translator/output/aws-us-gov/eventbridgerule_with_input_transformer.json @@ -0,0 +1,192 @@ +{ + "Resources": { + "ScheduledFunction": { + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip", + "S3ObjectVersion": "3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": [ + "ScheduledFunctionRole", + "Arn" + ] + }, + "Runtime": "python2.7", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::Lambda::Function" + }, + "ScheduledFunctionRole": { + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::IAM::Role" + }, + "ScheduledFunctionSchedule": { + "Properties": { + "ScheduleExpression": "rate(1 minute)", + "Targets": [ + { + "Arn": { + "Fn::GetAtt": [ + "ScheduledFunction", + "Arn" + ] + }, + "Id": "ScheduledFunctionScheduleLambdaTarget" + } + ] + }, + "Type": "AWS::Events::Rule" + }, + "ScheduledFunctionSchedulePermission": { + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Ref": "ScheduledFunction" + }, + "Principal": "events.amazonaws.com", + "SourceArn": { + "Fn::GetAtt": [ + "ScheduledFunctionSchedule", + "Arn" + ] + } + }, + "Type": "AWS::Lambda::Permission" + }, + "TriggeredFunction": { + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip", + "S3ObjectVersion": "3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": [ + "TriggeredFunctionRole", + "Arn" + ] + }, + "Runtime": "python2.7", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::Lambda::Function" + }, + "TriggeredFunctionOnTerminate": { + "Properties": { + "EventBusName": "ExternalEventBridge", + "EventPattern": { + "detail": { + "state": [ + "terminated" + ] + } + }, + "Targets": [ + { + "Arn": { + "Fn::GetAtt": [ + "TriggeredFunction", + "Arn" + ] + }, + "Id": "hello345", + "InputTransformer": { + "InputPathsMap": { + "instance": "$.detail.instance-id", + "state": "$.detail.state" + }, + "InputTemplate": "{\n\"instance\" : ,\n\"state\" : ,\n\"instanceStatus\": \"instance \\\"\\\" is in \"\n}\n" + } + } + ] + }, + "Type": "AWS::Events::Rule" + }, + "TriggeredFunctionOnTerminatePermission": { + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Ref": "TriggeredFunction" + }, + "Principal": "events.amazonaws.com", + "SourceArn": { + "Fn::GetAtt": [ + "TriggeredFunctionOnTerminate", + "Arn" + ] + } + }, + "Type": "AWS::Lambda::Permission" + }, + "TriggeredFunctionRole": { + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::IAM::Role" + } + } +} diff --git a/tests/translator/output/eventbridgerule_with_input_transformer.json b/tests/translator/output/eventbridgerule_with_input_transformer.json new file mode 100644 index 000000000..461690b26 --- /dev/null +++ b/tests/translator/output/eventbridgerule_with_input_transformer.json @@ -0,0 +1,192 @@ +{ + "Resources": { + "ScheduledFunction": { + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip", + "S3ObjectVersion": "3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": [ + "ScheduledFunctionRole", + "Arn" + ] + }, + "Runtime": "python2.7", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::Lambda::Function" + }, + "ScheduledFunctionRole": { + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::IAM::Role" + }, + "ScheduledFunctionSchedule": { + "Properties": { + "ScheduleExpression": "rate(1 minute)", + "Targets": [ + { + "Arn": { + "Fn::GetAtt": [ + "ScheduledFunction", + "Arn" + ] + }, + "Id": "ScheduledFunctionScheduleLambdaTarget" + } + ] + }, + "Type": "AWS::Events::Rule" + }, + "ScheduledFunctionSchedulePermission": { + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Ref": "ScheduledFunction" + }, + "Principal": "events.amazonaws.com", + "SourceArn": { + "Fn::GetAtt": [ + "ScheduledFunctionSchedule", + "Arn" + ] + } + }, + "Type": "AWS::Lambda::Permission" + }, + "TriggeredFunction": { + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip", + "S3ObjectVersion": "3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": [ + "TriggeredFunctionRole", + "Arn" + ] + }, + "Runtime": "python2.7", + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::Lambda::Function" + }, + "TriggeredFunctionOnTerminate": { + "Properties": { + "EventBusName": "ExternalEventBridge", + "EventPattern": { + "detail": { + "state": [ + "terminated" + ] + } + }, + "Targets": [ + { + "Arn": { + "Fn::GetAtt": [ + "TriggeredFunction", + "Arn" + ] + }, + "Id": "hello345", + "InputTransformer": { + "InputPathsMap": { + "instance": "$.detail.instance-id", + "state": "$.detail.state" + }, + "InputTemplate": "{\n\"instance\" : ,\n\"state\" : ,\n\"instanceStatus\": \"instance \\\"\\\" is in \"\n}\n" + } + } + ] + }, + "Type": "AWS::Events::Rule" + }, + "TriggeredFunctionOnTerminatePermission": { + "Properties": { + "Action": "lambda:InvokeFunction", + "FunctionName": { + "Ref": "TriggeredFunction" + }, + "Principal": "events.amazonaws.com", + "SourceArn": { + "Fn::GetAtt": [ + "TriggeredFunctionOnTerminate", + "Arn" + ] + } + }, + "Type": "AWS::Lambda::Permission" + }, + "TriggeredFunctionRole": { + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Key": "lambda:createdBy", + "Value": "SAM" + } + ] + }, + "Type": "AWS::IAM::Role" + } + } +} From 60693537d79d20d865fadea010639e63de015cb0 Mon Sep 17 00:00:00 2001 From: connorrobertson Date: Tue, 1 Aug 2023 10:37:40 -0700 Subject: [PATCH 5/7] make schema --- samtranslator/schema/schema.json | 9 +++++++++ schema_source/sam.schema.json | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/samtranslator/schema/schema.json b/samtranslator/schema/schema.json index 9b5844674..09c52646c 100644 --- a/samtranslator/schema/schema.json +++ b/samtranslator/schema/schema.json @@ -246854,6 +246854,15 @@ "markdownDescription": "When you don't want to pass the entire matched event to the target, use the `InputPath` property to describe which part of the event to pass\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`InputPath`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputpath) property of an `AWS::Events::Rule Target` resource\\.", "title": "InputPath" }, + "InputTransformer": { + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "", + "title": "InputTransformer" + }, "Pattern": { "allOf": [ { diff --git a/schema_source/sam.schema.json b/schema_source/sam.schema.json index 33afd8ca9..44824e052 100644 --- a/schema_source/sam.schema.json +++ b/schema_source/sam.schema.json @@ -5086,6 +5086,15 @@ "markdownDescription": "When you don't want to pass the entire matched event to the target, use the `InputPath` property to describe which part of the event to pass\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`InputPath`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputpath) property of an `AWS::Events::Rule Target` resource\\.", "title": "InputPath" }, + "InputTransformer": { + "allOf": [ + { + "$ref": "#/definitions/PassThroughProp" + } + ], + "markdownDescription": "", + "title": "InputTransformer" + }, "Pattern": { "allOf": [ { From 8d542389bb0c0dc8026a10f706c1860e3efe0e3f Mon Sep 17 00:00:00 2001 From: connorrobertson Date: Wed, 2 Aug 2023 13:36:11 -0700 Subject: [PATCH 6/7] Make docs similar to how it is presented in Developer Guide --- .../internal/schema_source/aws_serverless_function.py | 2 +- samtranslator/internal/schema_source/sam-docs.json | 3 +-- samtranslator/schema/schema.json | 9 ++------- schema_source/sam.schema.json | 9 ++------- 4 files changed, 6 insertions(+), 17 deletions(-) diff --git a/samtranslator/internal/schema_source/aws_serverless_function.py b/samtranslator/internal/schema_source/aws_serverless_function.py index 69610babb..ec4ea65ea 100644 --- a/samtranslator/internal/schema_source/aws_serverless_function.py +++ b/samtranslator/internal/schema_source/aws_serverless_function.py @@ -333,7 +333,7 @@ class EventBridgeRuleEventProperties(BaseModel): Pattern: PassThroughProp = eventbridgeruleeventproperties("Pattern") RetryPolicy: Optional[PassThroughProp] = eventbridgeruleeventproperties("RetryPolicy") Target: Optional[EventBridgeRuleTarget] = eventbridgeruleeventproperties("Target") - InputTransformer: Optional[PassThroughProp] = eventbridgeruleeventproperties("InputTransformer") + InputTransformer: Optional[PassThroughProp] # TODO: add docs class EventBridgeRuleEvent(BaseModel): diff --git a/samtranslator/internal/schema_source/sam-docs.json b/samtranslator/internal/schema_source/sam-docs.json index 4d38288aa..44e36cb32 100644 --- a/samtranslator/internal/schema_source/sam-docs.json +++ b/samtranslator/internal/schema_source/sam-docs.json @@ -212,8 +212,7 @@ "RetryPolicy": "A `RetryPolicy` object that includes information about the retry policy settings\\. For more information, see [Event retry policy and using dead\\-letter queues](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html) in the *Amazon EventBridge User Guide*\\. \n*Type*: [RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`RetryPolicy`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy) property of the `AWS::Events::Rule` `Target` data type\\.", "RuleName": "The name of the rule\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Name`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-name) property of an `AWS::Events::Rule` resource\\.", "State": "The state of the rule\\. \n*Accepted values*: `DISABLED | ENABLED` \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the `[State](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-state) ` property of an `AWS::Events::Rule` resource\\.", - "Target": "The AWS resource that EventBridge invokes when a rule is triggered\\. You can use this property to specify the logical ID of the target\\. If this property is not specified, then AWS SAM generates the logical ID of the target\\. \n*Type*: [Target](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-target.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is similar to the [`Targets`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-targets) property of an `AWS::Events::Rule` resource\\. The AWS SAM version of this property only allows you to specify the logical ID of a single target\\.", - "InputTransformer": "" + "Target": "The AWS resource that EventBridge invokes when a rule is triggered\\. You can use this property to specify the logical ID of the target\\. If this property is not specified, then AWS SAM generates the logical ID of the target\\. \n*Type*: [Target](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-target.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is similar to the [`Targets`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-targets) property of an `AWS::Events::Rule` resource\\. The AWS SAM version of this property only allows you to specify the logical ID of a single target\\." }, "sam-property-function-eventinvokeconfiguration": { "DestinationConfig": "A configuration object that specifies the destination of an event after Lambda processes it\\. \n*Type*: [EventInvokeDestinationConfiguration](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-eventinvokedestinationconfiguration.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is similar to the [`DestinationConfig`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventinvokeconfig-destinationconfig.html) property of an `AWS::Lambda::EventInvokeConfig` resource\\. SAM requires an extra parameter, \"Type\", that does not exist in CloudFormation\\.", diff --git a/samtranslator/schema/schema.json b/samtranslator/schema/schema.json index 09c52646c..3f7b713a1 100644 --- a/samtranslator/schema/schema.json +++ b/samtranslator/schema/schema.json @@ -246855,13 +246855,8 @@ "title": "InputPath" }, "InputTransformer": { - "allOf": [ - { - "$ref": "#/definitions/PassThroughProp" - } - ], - "markdownDescription": "", - "title": "InputTransformer" + "title": "InputTransformer", + "type": "object" }, "Pattern": { "allOf": [ diff --git a/schema_source/sam.schema.json b/schema_source/sam.schema.json index 44824e052..fc080f9e8 100644 --- a/schema_source/sam.schema.json +++ b/schema_source/sam.schema.json @@ -5087,13 +5087,8 @@ "title": "InputPath" }, "InputTransformer": { - "allOf": [ - { - "$ref": "#/definitions/PassThroughProp" - } - ], - "markdownDescription": "", - "title": "InputTransformer" + "title": "InputTransformer", + "type": "object" }, "Pattern": { "allOf": [ From edd4e1ca413a2e2501296abb2129647c84bc7f52 Mon Sep 17 00:00:00 2001 From: connorrobertson Date: Wed, 2 Aug 2023 13:42:52 -0700 Subject: [PATCH 7/7] Ran make schema --- samtranslator/schema/schema.json | 3 +-- schema_source/sam.schema.json | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/samtranslator/schema/schema.json b/samtranslator/schema/schema.json index 3f7b713a1..993af5265 100644 --- a/samtranslator/schema/schema.json +++ b/samtranslator/schema/schema.json @@ -246855,8 +246855,7 @@ "title": "InputPath" }, "InputTransformer": { - "title": "InputTransformer", - "type": "object" + "$ref": "#/definitions/PassThroughProp" }, "Pattern": { "allOf": [ diff --git a/schema_source/sam.schema.json b/schema_source/sam.schema.json index fc080f9e8..499662cec 100644 --- a/schema_source/sam.schema.json +++ b/schema_source/sam.schema.json @@ -5087,8 +5087,7 @@ "title": "InputPath" }, "InputTransformer": { - "title": "InputTransformer", - "type": "object" + "$ref": "#/definitions/PassThroughProp" }, "Pattern": { "allOf": [