From 4ba20fd2f1579034483683995fac1e18e97a1b12 Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Mon, 6 Jul 2020 15:05:22 +0200 Subject: [PATCH 1/5] feat(lambda-nodejs): allow jsx and tsx entry files (#8892) Support JSX adn TSX for entry files ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-lambda-nodejs/README.md | 2 +- .../@aws-cdk/aws-lambda-nodejs/lib/function.ts | 2 +- .../aws-lambda-nodejs/test/function.test.ts | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-lambda-nodejs/README.md b/packages/@aws-cdk/aws-lambda-nodejs/README.md index b4e4579991f9e..20b79f7878cdc 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/README.md +++ b/packages/@aws-cdk/aws-lambda-nodejs/README.md @@ -34,7 +34,7 @@ automatically transpiled and bundled whether it's written in JavaScript or TypeS Alternatively, an entry file and handler can be specified: ```ts new lambda.NodejsFunction(this, 'MyFunction', { - entry: '/path/to/my/file.ts', + entry: '/path/to/my/file.ts', // accepts .js, .jsx, .ts and .tsx files handler: 'myExportedFunc' }); ``` diff --git a/packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts b/packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts index 1138807443fec..3f623aa08e94f 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts +++ b/packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts @@ -84,7 +84,7 @@ export class NodejsFunction extends lambda.Function { */ function findEntry(id: string, entry?: string): string { if (entry) { - if (!/\.(js|ts)$/.test(entry)) { + if (!/\.(jsx?|tsx?)$/.test(entry)) { throw new Error('Only JavaScript or TypeScript entry files are supported.'); } if (!fs.existsSync(entry)) { diff --git a/packages/@aws-cdk/aws-lambda-nodejs/test/function.test.ts b/packages/@aws-cdk/aws-lambda-nodejs/test/function.test.ts index 200200fdeb1ce..fca00ea0f9562 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/test/function.test.ts +++ b/packages/@aws-cdk/aws-lambda-nodejs/test/function.test.ts @@ -1,6 +1,8 @@ import '@aws-cdk/assert/jest'; import { Runtime } from '@aws-cdk/aws-lambda'; import { Stack } from '@aws-cdk/core'; +import * as fs from 'fs'; +import * as path from 'path'; import { NodejsFunction } from '../lib'; import { Bundling } from '../lib/bundling'; @@ -67,6 +69,18 @@ test('throws when entry is not js/ts', () => { })).toThrow(/Only JavaScript or TypeScript entry files are supported/); }); +test('accepts tsx', () => { + const entry = path.join(__dirname, 'handler.tsx'); + + fs.symlinkSync(path.join(__dirname, 'function.test.handler1.ts'), entry); + + expect(() => new NodejsFunction(stack, 'Fn', { + entry, + })).not.toThrow(); + + fs.unlinkSync(entry); +}); + test('throws when entry does not exist', () => { expect(() => new NodejsFunction(stack, 'Fn', { entry: 'notfound.ts', From 021533caa8f4e515299d1f0cdaadd9f625d6f64d Mon Sep 17 00:00:00 2001 From: Shiv Lakshminarayan Date: Mon, 6 Jul 2020 07:42:14 -0700 Subject: [PATCH 2/5] feat(stepfunctions-tasks): task for invoking a Step Functions activity worker (#8840) Replacement class for `InvokeActivity` which currently uses the embedded task. The notable changes are: * This change merges task and service integration level properties by extending `TaskStateBase`, similar to all the other task states. * `activity` is now a property in the new class and not specified in the constructor I've left the current tests intact for fidelity and updated the `README` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../aws-stepfunctions-tasks/README.md | 31 +++++++ .../aws-stepfunctions-tasks/lib/index.ts | 1 + .../lib/invoke-activity.ts | 2 + .../lib/stepfunctions/invoke-activity.ts | 44 ++++++++++ .../integ.invoke-activity.expected.json | 85 +++++++++++++++++++ .../stepfunctions/integ.invoke-activity.ts | 69 +++++++++++++++ .../test/stepfunctions/invoke-activity.ts | 64 ++++++++++++++ 7 files changed, 296 insertions(+) create mode 100644 packages/@aws-cdk/aws-stepfunctions-tasks/lib/stepfunctions/invoke-activity.ts create mode 100644 packages/@aws-cdk/aws-stepfunctions-tasks/test/stepfunctions/integ.invoke-activity.expected.json create mode 100644 packages/@aws-cdk/aws-stepfunctions-tasks/test/stepfunctions/integ.invoke-activity.ts create mode 100644 packages/@aws-cdk/aws-stepfunctions-tasks/test/stepfunctions/invoke-activity.ts diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/README.md b/packages/@aws-cdk/aws-stepfunctions-tasks/README.md index d5142e2159d2b..eb391390b2056 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/README.md +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/README.md @@ -54,6 +54,8 @@ This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aw - [Create Transform Job](#create-transform-job) - [SNS](#sns) - [Step Functions](#step-functions) + - [Start Execution](#start-execution) + - [Invoke Activity Worker](#invoke-activity) - [SQS](#sqs) ## Task @@ -750,6 +752,8 @@ const task2 = new tasks.SnsPublish(this, 'Publish2', { ## Step Functions +### Start Execution + You can manage [AWS Step Functions](https://docs.aws.amazon.com/step-functions/latest/dg/connect-stepfunctions.html) executions. AWS Step Functions supports it's own [`StartExecution`](https://docs.aws.amazon.com/step-functions/latest/apireference/API_StartExecution.html) API as a service integration. @@ -777,6 +781,33 @@ new sfn.StateMachine(stack, 'ParentStateMachine', { }); ``` +### Invoke Activity + +You can invoke a [Step Functions Activity](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-activities.html) which enables you to have +a task in your state machine where the work is performed by a *worker* that can +be hosted on Amazon EC2, Amazon ECS, AWS Lambda, basically anywhere. Activities +are a way to associate code running somewhere (known as an activity worker) with +a specific task in a state machine. + +When Step Functions reaches an activity task state, the workflow waits for an +activity worker to poll for a task. An activity worker polls Step Functions by +using GetActivityTask, and sending the ARN for the related activity. + +After the activity worker completes its work, it can provide a report of its +success or failure by using `SendTaskSuccess` or `SendTaskFailure`. These two +calls use the taskToken provided by GetActivityTask to associate the result +with that task. + +The following example creates an activity and creates a task that invokes the activity. + +```ts +const submitJobActivity = new sfn.Activity(this, 'SubmitJob'); + +new tasks.StepFunctionsInvokeActivity(this, 'Submit Job', { + activity: submitJobActivity, +}); +``` + ## SQS Step Functions supports [Amazon SQS](https://docs.aws.amazon.com/step-functions/latest/dg/connect-sqs.html) diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/index.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/index.ts index 68d8c30b93997..ee034e389ad96 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/index.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/index.ts @@ -16,6 +16,7 @@ export * from './sagemaker/create-training-job'; export * from './sagemaker/create-transform-job'; export * from './start-execution'; export * from './stepfunctions/start-execution'; +export * from './stepfunctions/invoke-activity'; export * from './evaluate-expression'; export * from './emr/emr-create-cluster'; export * from './emr/emr-set-cluster-termination-protection'; diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/invoke-activity.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/invoke-activity.ts index e9d6342fefcc4..a0c78b5cf073c 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/invoke-activity.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/invoke-activity.ts @@ -19,6 +19,8 @@ export interface InvokeActivityProps { * A Step Functions Task to invoke an Activity worker. * * An Activity can be used directly as a Resource. + * + * @deprecated - use `StepFunctionsInvokeActivity` */ export class InvokeActivity implements sfn.IStepFunctionsTask { constructor(private readonly activity: sfn.IActivity, private readonly props: InvokeActivityProps = {}) { diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/stepfunctions/invoke-activity.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/stepfunctions/invoke-activity.ts new file mode 100644 index 0000000000000..829a35eb03658 --- /dev/null +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/stepfunctions/invoke-activity.ts @@ -0,0 +1,44 @@ +import * as iam from '@aws-cdk/aws-iam'; +import * as sfn from '@aws-cdk/aws-stepfunctions'; +import * as cdk from '@aws-cdk/core'; + +/** + * Properties for invoking an Activity worker + */ +export interface StepFunctionsInvokeActivityProps extends sfn.TaskStateBaseProps { + + /** + * Step Functions Activity to invoke + */ + readonly activity: sfn.IActivity +} + +/** + * A Step Functions Task to invoke an Activity worker. + * + * An Activity can be used directly as a Resource. + */ +export class StepFunctionsInvokeActivity extends sfn.TaskStateBase { + protected readonly taskMetrics?: sfn.TaskMetricsConfig; + // No IAM permissions necessary, execution role implicitly has Activity permissions. + protected readonly taskPolicies?: iam.PolicyStatement[]; + + constructor(scope: cdk.Construct, id: string, private readonly props: StepFunctionsInvokeActivityProps) { + super(scope, id, props); + + this.taskMetrics = { + metricDimensions: { ActivityArn: this.props.activity.activityArn }, + metricPrefixSingular: 'Activity', + metricPrefixPlural: 'Activities', + }; + } + + /** + * @internal + */ + protected _renderTask(): any { + return { + Resource: this.props.activity.activityArn, + }; + } +} diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/stepfunctions/integ.invoke-activity.expected.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/stepfunctions/integ.invoke-activity.expected.json new file mode 100644 index 0000000000000..e58efc93007de --- /dev/null +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/stepfunctions/integ.invoke-activity.expected.json @@ -0,0 +1,85 @@ +{ + "Resources": { + "SubmitJobFB773A16": { + "Type": "AWS::StepFunctions::Activity", + "Properties": { + "Name": "awsstepfunctionsintegSubmitJobA2508960" + } + }, + "CheckJob5FFC1D6F": { + "Type": "AWS::StepFunctions::Activity", + "Properties": { + "Name": "awsstepfunctionsintegCheckJobC4AC762D" + } + }, + "StateMachineRoleB840431D": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": { + "Fn::Join": [ + "", + [ + "states.", + { + "Ref": "AWS::Region" + }, + ".amazonaws.com" + ] + ] + } + } + } + ], + "Version": "2012-10-17" + } + } + }, + "StateMachine2E01A3A5": { + "Type": "AWS::StepFunctions::StateMachine", + "Properties": { + "RoleArn": { + "Fn::GetAtt": [ + "StateMachineRoleB840431D", + "Arn" + ] + }, + "DefinitionString": { + "Fn::Join": [ + "", + [ + "{\"StartAt\":\"Submit Job\",\"States\":{\"Submit Job\":{\"Next\":\"Wait X Seconds\",\"Type\":\"Task\",\"ResultPath\":\"$.guid\",\"Resource\":\"", + { + "Ref": "SubmitJobFB773A16" + }, + "\"},\"Wait X Seconds\":{\"Type\":\"Wait\",\"SecondsPath\":\"$.wait_time\",\"Next\":\"Get Job Status\"},\"Get Job Status\":{\"Next\":\"Job Complete?\",\"Type\":\"Task\",\"InputPath\":\"$.guid\",\"ResultPath\":\"$.status\",\"Resource\":\"", + { + "Ref": "CheckJob5FFC1D6F" + }, + "\"},\"Job Complete?\":{\"Type\":\"Choice\",\"Choices\":[{\"Variable\":\"$.status\",\"StringEquals\":\"FAILED\",\"Next\":\"Job Failed\"},{\"Variable\":\"$.status\",\"StringEquals\":\"SUCCEEDED\",\"Next\":\"Get Final Job Status\"}],\"Default\":\"Wait X Seconds\"},\"Job Failed\":{\"Type\":\"Fail\",\"Error\":\"DescribeJob returned FAILED\",\"Cause\":\"AWS Batch Job Failed\"},\"Get Final Job Status\":{\"End\":true,\"Type\":\"Task\",\"InputPath\":\"$.guid\",\"Resource\":\"", + { + "Ref": "CheckJob5FFC1D6F" + }, + "\"}},\"TimeoutSeconds\":300}" + ] + ] + } + }, + "DependsOn": [ + "StateMachineRoleB840431D" + ] + } + }, + "Outputs": { + "stateMachineArn": { + "Value": { + "Ref": "StateMachine2E01A3A5" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/stepfunctions/integ.invoke-activity.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/test/stepfunctions/integ.invoke-activity.ts new file mode 100644 index 0000000000000..918c31d809aaf --- /dev/null +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/stepfunctions/integ.invoke-activity.ts @@ -0,0 +1,69 @@ +import * as sfn from '@aws-cdk/aws-stepfunctions'; +import * as cdk from '@aws-cdk/core'; +import * as tasks from '../../lib'; + +/* + * Creates a state machine with a job poller sample project + * https://docs.aws.amazon.com/step-functions/latest/dg/sample-project-job-poller.html + * + * Stack verification steps: + * The generated State Machine can be executed from the CLI (or Step Functions console) + * and runs with an execution status of `Running`. + * + * An external process can call the state machine to send a heartbeat or response before it times out. + * + * -- aws stepfunctions start-execution --state-machine-arn provides execution arn + * -- aws stepfunctions describe-execution --execution-arn returns a status of `Running` + * + * CHANGEME: extend this test to create the external resources to report heartbeats + */ +class InvokeActivityStack extends cdk.Stack { + constructor(scope: cdk.App, id: string, props: cdk.StackProps = {}) { + super(scope, id, props); + + const submitJobActivity = new sfn.Activity(this, 'SubmitJob'); + const checkJobActivity = new sfn.Activity(this, 'CheckJob'); + + const submitJob = new tasks.StepFunctionsInvokeActivity(this, 'Submit Job', { + activity: submitJobActivity, + resultPath: '$.guid', + }); + const waitX = new sfn.Wait(this, 'Wait X Seconds', { time: sfn.WaitTime.secondsPath('$.wait_time') }); + const getStatus = new tasks.StepFunctionsInvokeActivity(this, 'Get Job Status', { + activity: checkJobActivity, + inputPath: '$.guid', + resultPath: '$.status', + }); + const isComplete = new sfn.Choice(this, 'Job Complete?'); + const jobFailed = new sfn.Fail(this, 'Job Failed', { + cause: 'AWS Batch Job Failed', + error: 'DescribeJob returned FAILED', + }); + const finalStatus = new tasks.StepFunctionsInvokeActivity(this, 'Get Final Job Status', { + activity: checkJobActivity, + inputPath: '$.guid', + }); + + const chain = sfn.Chain + .start(submitJob) + .next(waitX) + .next(getStatus) + .next(isComplete + .when(sfn.Condition.stringEquals('$.status', 'FAILED'), jobFailed) + .when(sfn.Condition.stringEquals('$.status', 'SUCCEEDED'), finalStatus) + .otherwise(waitX)); + + const sm = new sfn.StateMachine(this, 'StateMachine', { + definition: chain, + timeout: cdk.Duration.seconds(300), + }); + + new cdk.CfnOutput(this, 'stateMachineArn', { + value: sm.stateMachineArn, + }); + } +} + +const app = new cdk.App(); +new InvokeActivityStack(app, 'aws-stepfunctions-integ'); +app.synth(); diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/stepfunctions/invoke-activity.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/test/stepfunctions/invoke-activity.ts new file mode 100644 index 0000000000000..940517e6bdbf7 --- /dev/null +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/stepfunctions/invoke-activity.ts @@ -0,0 +1,64 @@ +import '@aws-cdk/assert/jest'; +import * as sfn from '@aws-cdk/aws-stepfunctions'; +import { Stack } from '@aws-cdk/core'; +import { StepFunctionsInvokeActivity } from '../../lib/stepfunctions/invoke-activity'; + +test('Activity can be used in a Task', () => { + // GIVEN + const stack = new Stack(); + + // WHEN + const activity = new sfn.Activity(stack, 'Activity'); + const task = new StepFunctionsInvokeActivity(stack, 'Task', { activity }); + new sfn.StateMachine(stack, 'SM', { + definition: task, + }); + + // THEN + expect(stack).toHaveResource('AWS::StepFunctions::StateMachine', { + DefinitionString: { + 'Fn::Join': ['', [ + '{"StartAt":"Task","States":{"Task":{"End":true,"Type":"Task","Resource":"', + { Ref: 'Activity04690B0A' }, + '"}}}', + ]], + }, + }); +}); + +test('Activity Task metrics and Activity metrics are the same', () => { + // GIVEN + const stack = new Stack(); + const activity = new sfn.Activity(stack, 'Activity'); + const task = new StepFunctionsInvokeActivity(stack, 'Invoke', {activity }); + + // WHEN + const activityMetrics = [ + activity.metricFailed(), + activity.metricHeartbeatTimedOut(), + activity.metricRunTime(), + activity.metricScheduled(), + activity.metricScheduleTime(), + activity.metricStarted(), + activity.metricSucceeded(), + activity.metricTime(), + activity.metricTimedOut(), + ]; + + const taskMetrics = [ + task.metricFailed(), + task.metricHeartbeatTimedOut(), + task.metricRunTime(), + task.metricScheduled(), + task.metricScheduleTime(), + task.metricStarted(), + task.metricSucceeded(), + task.metricTime(), + task.metricTimedOut(), + ]; + + // THEN + for (let i = 0; i < activityMetrics.length; i++) { + expect(activityMetrics[i]).toEqual(taskMetrics[i]); + } +}); From 33263d7bce032307eb7779de85e07c681d245e67 Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Mon, 6 Jul 2020 17:02:54 +0200 Subject: [PATCH 3/5] chore(lambda-nodejs): make entry file path absolute (#8874) Although I haven't seen issues with a relative entry file path, it is safer to use a absolute one. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts | 4 ++-- .../@aws-cdk/aws-lambda-nodejs/test/function.test.ts | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts b/packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts index 3f623aa08e94f..1215330212436 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts +++ b/packages/@aws-cdk/aws-lambda-nodejs/lib/function.ts @@ -47,7 +47,7 @@ export class NodejsFunction extends lambda.Function { } // Entry and defaults - const entry = findEntry(id, props.entry); + const entry = path.resolve(findEntry(id, props.entry)); const handler = props.handler ?? 'handler'; const defaultRunTime = nodeMajorVersion() >= 12 ? lambda.Runtime.NODEJS_12_X @@ -63,9 +63,9 @@ export class NodejsFunction extends lambda.Function { ...props, runtime, code: Bundling.parcel({ + ...props, entry, runtime, - ...props, }), handler: `index.${handler}`, }); diff --git a/packages/@aws-cdk/aws-lambda-nodejs/test/function.test.ts b/packages/@aws-cdk/aws-lambda-nodejs/test/function.test.ts index fca00ea0f9562..e8f559fdfbec5 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/test/function.test.ts +++ b/packages/@aws-cdk/aws-lambda-nodejs/test/function.test.ts @@ -96,3 +96,14 @@ test('throws with the wrong runtime family', () => { runtime: Runtime.PYTHON_3_8, })).toThrow(/Only `NODEJS` runtimes are supported/); }); + +test('resolves entry to an absolute path', () => { + // WHEN + new NodejsFunction(stack, 'fn', { + entry: 'lib/index.ts', + }); + + expect(Bundling.parcel).toHaveBeenCalledWith(expect.objectContaining({ + entry: expect.stringMatching(/@aws-cdk\/aws-lambda-nodejs\/lib\/index.ts$/), + })); +}); From c585e1873e437341ac1b90afbe85a9cb9e6dc2d6 Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Mon, 6 Jul 2020 17:23:05 +0200 Subject: [PATCH 4/5] fix(lambda-nodejs): maximum call stack size exceeded with relative entry file path (#8907) Use absolute paths in `findUp()` to avoid this. Fixes #8902 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-lambda-nodejs/lib/util.ts | 14 +++++++++----- .../@aws-cdk/aws-lambda-nodejs/test/util.test.ts | 6 ++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/@aws-cdk/aws-lambda-nodejs/lib/util.ts b/packages/@aws-cdk/aws-lambda-nodejs/lib/util.ts index 6b3f7f8173a02..9bdab8776c86c 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/lib/util.ts +++ b/packages/@aws-cdk/aws-lambda-nodejs/lib/util.ts @@ -54,12 +54,16 @@ export function nodeMajorVersion(): number { * Find a file by walking up parent directories */ export function findUp(name: string, directory: string = process.cwd()): string | undefined { - const { root } = path.parse(directory); - if (directory === root && !fs.existsSync(path.join(directory, name))) { - return undefined; - } + const absoluteDirectory = path.resolve(directory); + if (fs.existsSync(path.join(directory, name))) { return directory; } - return findUp(name, path.dirname(directory)); + + const { root } = path.parse(absoluteDirectory); + if (absoluteDirectory === root) { + return undefined; + } + + return findUp(name, path.dirname(absoluteDirectory)); } diff --git a/packages/@aws-cdk/aws-lambda-nodejs/test/util.test.ts b/packages/@aws-cdk/aws-lambda-nodejs/test/util.test.ts index 026f2bcb519e3..a85b0064cef85 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/test/util.test.ts +++ b/packages/@aws-cdk/aws-lambda-nodejs/test/util.test.ts @@ -10,4 +10,10 @@ test('findUp', () => { // Starting at a specific path expect(findUp('util.test.ts', path.join(__dirname, 'integ-handlers'))).toMatch(/aws-lambda-nodejs\/test$/); + + // Non existing file starting at a non existing relative path + expect(findUp('not-to-be-found.txt', 'non-existing/relative/path')).toBe(undefined); + + // Starting at a relative path + expect(findUp('util.test.ts', 'test/integ-handlers')).toMatch(/aws-lambda-nodejs\/test$/); }); From 755648a7d3e318dc63fafed2c75e720f1e9a56ed Mon Sep 17 00:00:00 2001 From: Shiv Lakshminarayan Date: Mon, 6 Jul 2020 08:42:48 -0700 Subject: [PATCH 5/5] chore(stepfunctions): mark the task class as deprecated (#8829) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-stepfunctions/lib/states/task.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/@aws-cdk/aws-stepfunctions/lib/states/task.ts b/packages/@aws-cdk/aws-stepfunctions/lib/states/task.ts index 1d275d3fb25f8..29a1d6845aeb9 100644 --- a/packages/@aws-cdk/aws-stepfunctions/lib/states/task.ts +++ b/packages/@aws-cdk/aws-stepfunctions/lib/states/task.ts @@ -11,6 +11,8 @@ import { renderJsonPath, State } from './state'; /** * Props that are common to all tasks + * + * @deprecated - replaced by service integration specific classes (i.e. LambdaInvoke, SnsPublish) */ export interface TaskProps { /** @@ -98,6 +100,8 @@ export interface TaskProps { * * For some resource types, more specific subclasses of Task may be available * which are more convenient to use. + * + * @deprecated - replaced by service integration specific classes (i.e. LambdaInvoke, SnsPublish) */ export class Task extends State implements INextable { public readonly endStates: INextable[];