konokenj.cdk-api-mcp-server 0.40.0__py3-none-any.whl → 0.42.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of konokenj.cdk-api-mcp-server might be problematic. Click here for more details.
- cdk_api_mcp_server/__about__.py +1 -1
- cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-bedrock-alpha/README.md +540 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-eks-v2-alpha/README.md +44 -46
- cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-lambda-python-alpha/README.md +6 -6
- cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-s3tables-alpha/README.md +28 -1
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/README.md/README.md +364 -16
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/README.md +144 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/integ.api-dualstack.ts +3 -4
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/integ.api.ts +2 -4
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/integ.stage.ts +7 -20
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/integ.usage-plan.ts +80 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-authorizers/integ.iam.ts +34 -38
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-integrations/integ.sqs.ts +58 -71
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codepipeline-actions/integ.pipeline-elastic-beanstalk-deploy.ts +1 -1
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cognito/README.md +11 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cognito/integ.user-pool-client-explicit-props.ts +1 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/README.md +38 -13
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/integ.dynamodb-v2.cci.ts +49 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/integ.dynamodb.cci.ts +27 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/integ.dynamodb.contirubtor-insights-for-gsi.ts +6 -2
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/integ.table-v2-global.ts +9 -3
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/README.md +3 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.ebs-volume-initialization-rate.ts +80 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs-patterns/README.md +2 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs-patterns/integ.alb-fargate-service-smart-defaults.ts +143 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-events/README.md +25 -3
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-events/integ.archive-customer-managed-key.ts +23 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/README.md +2 -2
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-route53/integ.delete-existing-record-set.ts +0 -1
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/README.md +18 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-cross-stack-ssm-source.ts +91 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-signer/integ.signing-profile.ts +5 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-sns/README.md +2 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-sns-subscriptions/integ.sns-sqs-subscription-filter.ts +75 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-sns-subscriptions/integ.sns-sqs.ts +21 -40
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/README.md +9 -3
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.invoke-jsonata.ts +87 -80
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.invoke.ts +87 -69
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.start-job-run.ts +102 -104
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/core/README.md +2 -1893
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/cx-api/FEATURE_FLAGS.md +52 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/cx-api/README.md +24 -1
- {konokenj_cdk_api_mcp_server-0.40.0.dist-info → konokenj_cdk_api_mcp_server-0.42.0.dist-info}/METADATA +2 -2
- {konokenj_cdk_api_mcp_server-0.40.0.dist-info → konokenj_cdk_api_mcp_server-0.42.0.dist-info}/RECORD +47 -39
- {konokenj_cdk_api_mcp_server-0.40.0.dist-info → konokenj_cdk_api_mcp_server-0.42.0.dist-info}/WHEEL +0 -0
- {konokenj_cdk_api_mcp_server-0.40.0.dist-info → konokenj_cdk_api_mcp_server-0.42.0.dist-info}/entry_points.txt +0 -0
- {konokenj_cdk_api_mcp_server-0.40.0.dist-info → konokenj_cdk_api_mcp_server-0.42.0.dist-info}/licenses/LICENSE.txt +0 -0
cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/README.md
CHANGED
|
@@ -34,6 +34,8 @@ This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aw
|
|
|
34
34
|
- [SubmitJob](#submitjob)
|
|
35
35
|
- [Bedrock](#bedrock)
|
|
36
36
|
- [InvokeModel](#invokemodel)
|
|
37
|
+
- [Using Input Path for S3 URI](#using-input-path-for-s3-uri)
|
|
38
|
+
- [Using Input Path](#using-input-path)
|
|
37
39
|
- [createModelCustomizationJob](#createmodelcustomizationjob)
|
|
38
40
|
- [CodeBuild](#codebuild)
|
|
39
41
|
- [StartBuild](#startbuild)
|
|
@@ -47,6 +49,7 @@ This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aw
|
|
|
47
49
|
- [RunTask](#runtask)
|
|
48
50
|
- [EC2](#ec2)
|
|
49
51
|
- [Fargate](#fargate)
|
|
52
|
+
- [Override CPU and Memory Parameter](#override-cpu-and-memory-parameter)
|
|
50
53
|
- [ECS enable Exec](#ecs-enable-exec)
|
|
51
54
|
- [EMR](#emr)
|
|
52
55
|
- [Create Cluster](#create-cluster)
|
|
@@ -64,15 +67,18 @@ This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aw
|
|
|
64
67
|
- [Call](#call)
|
|
65
68
|
- [EventBridge](#eventbridge)
|
|
66
69
|
- [Put Events](#put-events)
|
|
70
|
+
- [EventBridge Scheduler](#eventbridge-scheduler)
|
|
71
|
+
- [Create Scheduler](#create-scheduler)
|
|
67
72
|
- [Glue](#glue)
|
|
68
73
|
- [StartJobRun](#startjobrun)
|
|
69
74
|
- [StartCrawlerRun](#startcrawlerrun)
|
|
70
75
|
- [Glue DataBrew](#glue-databrew)
|
|
71
76
|
- [Start Job Run](#start-job-run-1)
|
|
77
|
+
- [Invoke HTTP API](#invoke-http-api)
|
|
72
78
|
- [Lambda](#lambda)
|
|
73
79
|
- [Invoke](#invoke)
|
|
74
80
|
- [MediaConvert](#mediaconvert)
|
|
75
|
-
- [
|
|
81
|
+
- [CreateJob](#createjob)
|
|
76
82
|
- [SageMaker](#sagemaker)
|
|
77
83
|
- [Create Training Job](#create-training-job)
|
|
78
84
|
- [Create Transform Job](#create-transform-job)
|
|
@@ -1315,12 +1321,12 @@ The following code snippet includes a Task state that uses eks:call to list the
|
|
|
1315
1321
|
|
|
1316
1322
|
```ts
|
|
1317
1323
|
import * as eks from 'aws-cdk-lib/aws-eks';
|
|
1318
|
-
import {
|
|
1324
|
+
import { KubectlV33Layer } from '@aws-cdk/lambda-layer-kubectl-v33';
|
|
1319
1325
|
|
|
1320
1326
|
const myEksCluster = new eks.Cluster(this, 'my sample cluster', {
|
|
1321
1327
|
version: eks.KubernetesVersion.V1_32,
|
|
1322
1328
|
clusterName: 'myEksCluster',
|
|
1323
|
-
kubectlLayer: new
|
|
1329
|
+
kubectlLayer: new KubectlV33Layer(this, 'kubectl'),
|
|
1324
1330
|
});
|
|
1325
1331
|
|
|
1326
1332
|
new tasks.EksCall(this, 'Call a EKS Endpoint', {
|
|
@@ -1,112 +1,119 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { IntegTest, ExpectedResult } from '@aws-cdk/integ-tests-alpha';
|
|
3
|
-
import * as cdk from 'aws-cdk-lib';
|
|
4
|
-
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
|
|
5
|
-
import * as events from 'aws-cdk-lib/aws-events';
|
|
1
|
+
import { Code, Function } from 'aws-cdk-lib/aws-lambda';
|
|
6
2
|
import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
|
|
7
|
-
import * as
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
3
|
+
import * as cdk from 'aws-cdk-lib';
|
|
4
|
+
import { LambdaInvoke } from 'aws-cdk-lib/aws-stepfunctions-tasks';
|
|
5
|
+
import { IntegTest, ExpectedResult } from '@aws-cdk/integ-tests-alpha';
|
|
6
|
+
import { STANDARD_NODEJS_RUNTIME } from '../../../config';
|
|
10
7
|
|
|
11
8
|
/*
|
|
12
|
-
* Creates
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* Creates a state machine with a task state to invoke a Lambda function
|
|
10
|
+
* The state machine creates a couple of Lambdas that pass results forward
|
|
11
|
+
* and into a Choice state that validates the output.
|
|
12
|
+
*
|
|
13
|
+
* Stack verification steps:
|
|
14
|
+
* The generated State Machine can be executed from the CLI (or Step Functions console)
|
|
15
|
+
* and runs with an execution status of `Succeeded`.
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* * aws stepfunctions describe-execution --execution-arn <execution-arn generated before> : should return status as SUCCEEDED
|
|
17
|
+
* -- aws stepfunctions start-execution --state-machine-arn <state-machine-arn-from-output> provides execution arn
|
|
18
|
+
* -- aws stepfunctions describe-execution --execution-arn <state-machine-arn-from-output> returns a status of `Succeeded`
|
|
19
19
|
*/
|
|
20
20
|
const app = new cdk.App({
|
|
21
21
|
postCliContext: {
|
|
22
22
|
'@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
|
|
23
23
|
},
|
|
24
24
|
});
|
|
25
|
-
const stack = new cdk.Stack(app, 'aws-stepfunctions-tasks-
|
|
25
|
+
const stack = new cdk.Stack(app, 'aws-stepfunctions-tasks-lambda-invoke-jsonata-integ');
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const submitJobLambda = new Function(stack, 'submitJobLambda', {
|
|
28
|
+
code: Code.fromInline(`exports.handler = async (event, context) => {
|
|
29
|
+
return {
|
|
30
|
+
statusCode: '200',
|
|
31
|
+
body: 'hello, world!',
|
|
32
|
+
...event,
|
|
33
|
+
};
|
|
34
|
+
};`),
|
|
35
|
+
runtime: STANDARD_NODEJS_RUNTIME,
|
|
36
|
+
handler: 'index.handler',
|
|
30
37
|
});
|
|
31
38
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
statusCode: '200',
|
|
46
|
-
responseTemplates: {
|
|
47
|
-
'application/json': JSON.stringify({ message: 'Hello, tester!' }),
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
passthroughBehavior: apigateway.PassthroughBehavior.NEVER,
|
|
52
|
-
requestTemplates: {
|
|
53
|
-
'application/json': '{ "statusCode": 200 }',
|
|
54
|
-
},
|
|
39
|
+
const submitJob = LambdaInvoke.jsonata(stack, 'Invoke Handler', {
|
|
40
|
+
lambdaFunction: submitJobLambda,
|
|
41
|
+
payload: sfn.TaskInput.fromObject({
|
|
42
|
+
execId: '{% $states.context.Execution.Id %}',
|
|
43
|
+
execInput: '{% $states.context.Execution.Input %}',
|
|
44
|
+
execName: '{% $states.context.Execution.Name %}',
|
|
45
|
+
execRoleArn: '{% $states.context.Execution.RoleArn %}',
|
|
46
|
+
execStartTime: '{% $states.context.Execution.StartTime %}',
|
|
47
|
+
stateEnteredTime: '{% $states.context.State.EnteredTime %}',
|
|
48
|
+
stateName: '{% $states.context.State.Name %}',
|
|
49
|
+
stateRetryCount: '{% $states.context.State.RetryCount %}',
|
|
50
|
+
stateMachineId: '{% $states.context.StateMachine.Id %}',
|
|
51
|
+
stateMachineName: '{% $states.context.StateMachine.Name %}',
|
|
55
52
|
}),
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
methodResponses: [
|
|
59
|
-
{
|
|
60
|
-
statusCode: '200',
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
);
|
|
53
|
+
outputs: '{% $states.result.Payload %}',
|
|
54
|
+
});
|
|
65
55
|
|
|
66
|
-
const
|
|
67
|
-
|
|
56
|
+
const checkJobStateLambda = new Function(stack, 'checkJobStateLambda', {
|
|
57
|
+
code: Code.fromInline(`exports.handler = async function(event, context) {
|
|
58
|
+
const expectedFields = [
|
|
59
|
+
'execId', 'execInput', 'execName', 'execRoleArn',
|
|
60
|
+
'execStartTime', 'stateEnteredTime', 'stateName',
|
|
61
|
+
'stateRetryCount', 'stateMachineId', 'stateMachineName',
|
|
62
|
+
];
|
|
63
|
+
const fieldsAreSet = expectedFields.every(field => event[field] !== undefined);
|
|
64
|
+
return {
|
|
65
|
+
status: event.statusCode === '200' && fieldsAreSet ? 'SUCCEEDED' : 'FAILED'
|
|
66
|
+
};
|
|
67
|
+
};`),
|
|
68
|
+
runtime: STANDARD_NODEJS_RUNTIME,
|
|
69
|
+
handler: 'index.handler',
|
|
68
70
|
});
|
|
69
71
|
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
apiEndpoint: sfn.TaskInput.fromText('{% $states.input.apiEndpoint %}'),
|
|
73
|
-
connection,
|
|
74
|
-
method: sfn.TaskInput.fromText('GET'),
|
|
72
|
+
const checkJobState = LambdaInvoke.jsonata(stack, 'Check the job state', {
|
|
73
|
+
lambdaFunction: checkJobStateLambda,
|
|
75
74
|
outputs: {
|
|
76
|
-
|
|
75
|
+
status: '{% $states.result.Payload.status %}',
|
|
77
76
|
},
|
|
78
77
|
});
|
|
79
78
|
|
|
79
|
+
const isComplete = sfn.Choice.jsonata(stack, 'Job Complete?');
|
|
80
|
+
const jobFailed = sfn.Fail.jsonata(stack, 'Job Failed', {
|
|
81
|
+
cause: 'Job Failed',
|
|
82
|
+
error: 'Received a status that was not 200',
|
|
83
|
+
});
|
|
84
|
+
const finalStatus = sfn.Pass.jsonata(stack, 'Final step');
|
|
85
|
+
|
|
86
|
+
const chain = sfn.Chain.start(submitJob)
|
|
87
|
+
.next(checkJobState)
|
|
88
|
+
.next(
|
|
89
|
+
isComplete
|
|
90
|
+
.when(sfn.Condition.jsonata("{% $states.input.status = 'FAILED' %}"), jobFailed)
|
|
91
|
+
.when(sfn.Condition.jsonata("{% $states.input.status = 'SUCCEEDED' %}"), finalStatus),
|
|
92
|
+
);
|
|
93
|
+
|
|
80
94
|
const sm = new sfn.StateMachine(stack, 'StateMachine', {
|
|
81
|
-
definition:
|
|
95
|
+
definition: chain,
|
|
82
96
|
timeout: cdk.Duration.seconds(30),
|
|
83
97
|
});
|
|
84
98
|
|
|
85
|
-
|
|
86
|
-
|
|
99
|
+
new cdk.CfnOutput(stack, 'stateMachineArn', {
|
|
100
|
+
value: sm.stateMachineArn,
|
|
87
101
|
});
|
|
88
102
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
stateMachineArn: sm.stateMachineArn,
|
|
92
|
-
input: JSON.stringify({
|
|
93
|
-
apiEndpoint: '/test',
|
|
94
|
-
}),
|
|
103
|
+
const integ = new IntegTest(app, 'IntegTest', {
|
|
104
|
+
testCases: [stack],
|
|
95
105
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const describe = testCase.assertions.awsApiCall('@aws-sdk/client-sfn', 'DescribeExecution', {
|
|
99
|
-
executionArn: start.getAttString('executionArn'),
|
|
106
|
+
const res = integ.assertions.awsApiCall('@aws-sdk/client-sfn', 'StartExecution', {
|
|
107
|
+
stateMachineArn: sm.stateMachineArn,
|
|
100
108
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
109
|
+
const executionArn = res.getAttString('executionArn');
|
|
110
|
+
integ.assertions.awsApiCall('@aws-sdk/client-sfn', 'DescribeExecution', {
|
|
111
|
+
executionArn,
|
|
112
|
+
}).expect(ExpectedResult.objectLike({
|
|
104
113
|
status: 'SUCCEEDED',
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}),
|
|
110
|
-
}));
|
|
114
|
+
})).waitForAssertions({
|
|
115
|
+
totalTimeout: cdk.Duration.seconds(10),
|
|
116
|
+
interval: cdk.Duration.seconds(3),
|
|
117
|
+
});
|
|
111
118
|
|
|
112
119
|
app.synth();
|
cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.invoke.ts
CHANGED
|
@@ -1,101 +1,119 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { IntegTest, ExpectedResult } from '@aws-cdk/integ-tests-alpha';
|
|
3
|
-
import * as cdk from 'aws-cdk-lib';
|
|
4
|
-
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
|
|
5
|
-
import * as events from 'aws-cdk-lib/aws-events';
|
|
1
|
+
import { Code, Function } from 'aws-cdk-lib/aws-lambda';
|
|
6
2
|
import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
|
|
7
|
-
import * as
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
3
|
+
import * as cdk from 'aws-cdk-lib';
|
|
4
|
+
import { LambdaInvoke } from 'aws-cdk-lib/aws-stepfunctions-tasks';
|
|
5
|
+
import { IntegTest, ExpectedResult } from '@aws-cdk/integ-tests-alpha';
|
|
6
|
+
import { STANDARD_NODEJS_RUNTIME } from '../../../config';
|
|
10
7
|
|
|
11
8
|
/*
|
|
12
|
-
* Creates
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* Creates a state machine with a task state to invoke a Lambda function
|
|
10
|
+
* The state machine creates a couple of Lambdas that pass results forward
|
|
11
|
+
* and into a Choice state that validates the output.
|
|
12
|
+
*
|
|
13
|
+
* Stack verification steps:
|
|
14
|
+
* The generated State Machine can be executed from the CLI (or Step Functions console)
|
|
15
|
+
* and runs with an execution status of `Succeeded`.
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* * aws stepfunctions describe-execution --execution-arn <execution-arn generated before> : should return status as SUCCEEDED
|
|
17
|
+
* -- aws stepfunctions start-execution --state-machine-arn <state-machine-arn-from-output> provides execution arn
|
|
18
|
+
* -- aws stepfunctions describe-execution --execution-arn <state-machine-arn-from-output> returns a status of `Succeeded`
|
|
19
19
|
*/
|
|
20
20
|
const app = new cdk.App({
|
|
21
21
|
postCliContext: {
|
|
22
22
|
'@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
|
|
23
23
|
},
|
|
24
24
|
});
|
|
25
|
-
const stack = new cdk.Stack(app, 'aws-stepfunctions-tasks-
|
|
25
|
+
const stack = new cdk.Stack(app, 'aws-stepfunctions-tasks-lambda-invoke-integ');
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const submitJobLambda = new Function(stack, 'submitJobLambda', {
|
|
28
|
+
code: Code.fromInline(`exports.handler = async (event, context) => {
|
|
29
|
+
return {
|
|
30
|
+
statusCode: '200',
|
|
31
|
+
body: 'hello, world!',
|
|
32
|
+
...event,
|
|
33
|
+
};
|
|
34
|
+
};`),
|
|
35
|
+
runtime: STANDARD_NODEJS_RUNTIME,
|
|
36
|
+
handler: 'index.handler',
|
|
30
37
|
});
|
|
31
38
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
const submitJob = new LambdaInvoke(stack, 'Invoke Handler', {
|
|
40
|
+
lambdaFunction: submitJobLambda,
|
|
41
|
+
payload: sfn.TaskInput.fromObject({
|
|
42
|
+
execId: sfn.JsonPath.executionId,
|
|
43
|
+
execInput: sfn.JsonPath.executionInput,
|
|
44
|
+
execName: sfn.JsonPath.executionName,
|
|
45
|
+
execRoleArn: sfn.JsonPath.executionRoleArn,
|
|
46
|
+
execStartTime: sfn.JsonPath.executionStartTime,
|
|
47
|
+
stateEnteredTime: sfn.JsonPath.stateEnteredTime,
|
|
48
|
+
stateName: sfn.JsonPath.stateName,
|
|
49
|
+
stateRetryCount: sfn.JsonPath.stateRetryCount,
|
|
50
|
+
stateMachineId: sfn.JsonPath.stateMachineId,
|
|
51
|
+
stateMachineName: sfn.JsonPath.stateMachineName,
|
|
52
|
+
}),
|
|
53
|
+
outputPath: '$.Payload',
|
|
36
54
|
});
|
|
37
55
|
|
|
38
|
-
const
|
|
56
|
+
const checkJobStateLambda = new Function(stack, 'checkJobStateLambda', {
|
|
57
|
+
code: Code.fromInline(`exports.handler = async function(event, context) {
|
|
58
|
+
const expectedFields = [
|
|
59
|
+
'execId', 'execInput', 'execName', 'execRoleArn',
|
|
60
|
+
'execStartTime', 'stateEnteredTime', 'stateName',
|
|
61
|
+
'stateRetryCount', 'stateMachineId', 'stateMachineName',
|
|
62
|
+
];
|
|
63
|
+
const fieldsAreSet = expectedFields.every(field => event[field] !== undefined);
|
|
64
|
+
return {
|
|
65
|
+
status: event.statusCode === '200' && fieldsAreSet ? 'SUCCEEDED' : 'FAILED'
|
|
66
|
+
};
|
|
67
|
+
};`),
|
|
68
|
+
runtime: STANDARD_NODEJS_RUNTIME,
|
|
69
|
+
handler: 'index.handler',
|
|
70
|
+
});
|
|
39
71
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
statusCode: '200',
|
|
46
|
-
responseTemplates: {
|
|
47
|
-
'application/json': JSON.stringify({ message: 'Hello, tester!' }),
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
passthroughBehavior: apigateway.PassthroughBehavior.NEVER,
|
|
52
|
-
requestTemplates: {
|
|
53
|
-
'application/json': '{ "statusCode": 200 }',
|
|
54
|
-
},
|
|
55
|
-
}),
|
|
56
|
-
{
|
|
57
|
-
authorizer,
|
|
58
|
-
methodResponses: [
|
|
59
|
-
{
|
|
60
|
-
statusCode: '200',
|
|
61
|
-
},
|
|
62
|
-
],
|
|
72
|
+
const checkJobState = new LambdaInvoke(stack, 'Check the job state', {
|
|
73
|
+
lambdaFunction: checkJobStateLambda,
|
|
74
|
+
resultSelector: {
|
|
75
|
+
status: sfn.JsonPath.stringAt('$.Payload.status'),
|
|
63
76
|
},
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const connection = new events.Connection(stack, 'Connection', {
|
|
67
|
-
authorization: events.Authorization.basic(username, cdk.SecretValue.unsafePlainText(password)),
|
|
68
77
|
});
|
|
69
78
|
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
method: sfn.TaskInput.fromText('GET'),
|
|
79
|
+
const isComplete = new sfn.Choice(stack, 'Job Complete?');
|
|
80
|
+
const jobFailed = new sfn.Fail(stack, 'Job Failed', {
|
|
81
|
+
cause: 'Job Failed',
|
|
82
|
+
error: 'Received a status that was not 200',
|
|
75
83
|
});
|
|
84
|
+
const finalStatus = new sfn.Pass(stack, 'Final step');
|
|
85
|
+
|
|
86
|
+
const chain = sfn.Chain.start(submitJob)
|
|
87
|
+
.next(checkJobState)
|
|
88
|
+
.next(
|
|
89
|
+
isComplete
|
|
90
|
+
.when(sfn.Condition.stringEquals('$.status', 'FAILED'), jobFailed)
|
|
91
|
+
.when(sfn.Condition.stringEquals('$.status', 'SUCCEEDED'), finalStatus),
|
|
92
|
+
);
|
|
76
93
|
|
|
77
94
|
const sm = new sfn.StateMachine(stack, 'StateMachine', {
|
|
78
|
-
definition:
|
|
95
|
+
definition: chain,
|
|
79
96
|
timeout: cdk.Duration.seconds(30),
|
|
80
97
|
});
|
|
81
98
|
|
|
82
|
-
|
|
83
|
-
|
|
99
|
+
new cdk.CfnOutput(stack, 'stateMachineArn', {
|
|
100
|
+
value: sm.stateMachineArn,
|
|
84
101
|
});
|
|
85
102
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
stateMachineArn: sm.stateMachineArn,
|
|
103
|
+
const integ = new IntegTest(app, 'IntegTest', {
|
|
104
|
+
testCases: [stack],
|
|
89
105
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const describe = testCase.assertions.awsApiCall('StepFunctions', 'describeExecution', {
|
|
93
|
-
executionArn: start.getAttString('executionArn'),
|
|
106
|
+
const res = integ.assertions.awsApiCall('StepFunctions', 'startExecution', {
|
|
107
|
+
stateMachineArn: sm.stateMachineArn,
|
|
94
108
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
109
|
+
const executionArn = res.getAttString('executionArn');
|
|
110
|
+
integ.assertions.awsApiCall('StepFunctions', 'describeExecution', {
|
|
111
|
+
executionArn,
|
|
112
|
+
}).expect(ExpectedResult.objectLike({
|
|
98
113
|
status: 'SUCCEEDED',
|
|
99
|
-
}))
|
|
114
|
+
})).waitForAssertions({
|
|
115
|
+
totalTimeout: cdk.Duration.seconds(10),
|
|
116
|
+
interval: cdk.Duration.seconds(3),
|
|
117
|
+
});
|
|
100
118
|
|
|
101
119
|
app.synth();
|