konokenj.cdk-api-mcp-server 0.26.0__py3-none-any.whl → 0.28.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.

Files changed (43) hide show
  1. cdk_api_mcp_server/__about__.py +1 -1
  2. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-amplify-alpha/README.md +14 -0
  3. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-bedrock-alpha/README.md +608 -0
  4. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigateway/integ.model-schema-additional-items.ts +72 -0
  5. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront/README.md +8 -0
  6. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront/integ.distribution-basic.ts +1 -1
  7. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codedeploy/integ.deployment-config.ts +15 -4
  8. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codedeploy/integ.deployment-group.ts +40 -218
  9. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codepipeline-actions/README.md +34 -0
  10. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codepipeline-actions/integ.pipeline-ec2-deploy-ssm-managed.ts +140 -0
  11. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codepipeline-actions/integ.pipeline-ec2-deploy.ts +140 -0
  12. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ec2/README.md +55 -1
  13. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ec2/integ.machine-image-cached.ts +53 -0
  14. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ec2/integ.volume-initialization-rate.ts +21 -0
  15. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/README.md +16 -0
  16. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.availability-zone-rebalancing.ts +4 -14
  17. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.enable-execute-command.ts +29 -35
  18. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.exec-command.ts +22 -16
  19. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.lb-awsvpc-nw.ts +16 -26
  20. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.pseudo-terminal.ts +8 -18
  21. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-eks/README.md +6 -0
  22. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-eks/integ.custom-addons.ts +48 -0
  23. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-logs/README.md +1 -0
  24. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-logs/integ.expose-metric-with-dimensions.ts +47 -0
  25. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-opensearchservice/integ.opensearch.gp3.ts +16 -1
  26. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-opensearchservice/integ.opensearch.https.ts +54 -0
  27. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/README.md +25 -2
  28. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/integ.cluster-serverless-v2-autopause.ts +27 -0
  29. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/integ.instance-from-cluster-snapshot.ts +23 -0
  30. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ssm/README.md +16 -0
  31. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions/README.md +21 -0
  32. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions/integ.map-jsonata-itemselector.ts +36 -0
  33. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.invoke-jsonata.ts +80 -87
  34. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.invoke.ts +69 -87
  35. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.start-job-run.ts +104 -102
  36. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-synthetics/README.md +23 -0
  37. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-synthetics/integ.canary-dryrun-update.ts +32 -0
  38. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-synthetics/integ.canary.ts +2 -0
  39. {konokenj_cdk_api_mcp_server-0.26.0.dist-info → konokenj_cdk_api_mcp_server-0.28.0.dist-info}/METADATA +2 -2
  40. {konokenj_cdk_api_mcp_server-0.26.0.dist-info → konokenj_cdk_api_mcp_server-0.28.0.dist-info}/RECORD +43 -30
  41. {konokenj_cdk_api_mcp_server-0.26.0.dist-info → konokenj_cdk_api_mcp_server-0.28.0.dist-info}/WHEEL +0 -0
  42. {konokenj_cdk_api_mcp_server-0.26.0.dist-info → konokenj_cdk_api_mcp_server-0.28.0.dist-info}/entry_points.txt +0 -0
  43. {konokenj_cdk_api_mcp_server-0.26.0.dist-info → konokenj_cdk_api_mcp_server-0.28.0.dist-info}/licenses/LICENSE.txt +0 -0
@@ -0,0 +1,48 @@
1
+ import * as ec2 from 'aws-cdk-lib/aws-ec2';
2
+ import { App, Stack } from 'aws-cdk-lib';
3
+ import { IntegTest } from '@aws-cdk/integ-tests-alpha';
4
+ import { getClusterVersionConfig } from './integ-tests-kubernetes-version';
5
+ import * as eks from 'aws-cdk-lib/aws-eks';
6
+
7
+ const app = new App({
8
+ postCliContext: {
9
+ '@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
10
+ },
11
+ });
12
+
13
+ const stack = new Stack(app, 'eks-custom-addons');
14
+
15
+ const vpc = new ec2.Vpc(stack, 'Vpc', { natGateways: 1, restrictDefaultSecurityGroup: false });
16
+
17
+ const cluster = new eks.Cluster(stack, 'Cluster', {
18
+ vpc,
19
+ ...getClusterVersionConfig(stack, eks.KubernetesVersion.V1_32),
20
+ defaultCapacity: 0,
21
+ bootstrapSelfManagedAddons: false,
22
+ });
23
+
24
+ const calico = new eks.HelmChart(stack, 'Calico', {
25
+ cluster,
26
+ release: 'calico',
27
+ chart: 'tigera-operator',
28
+ repository: 'https://docs.tigera.io/calico/charts',
29
+ namespace: 'tigera-operator',
30
+ version: 'v3.30.1',
31
+ createNamespace: true,
32
+ });
33
+
34
+ const cnipatch = new eks.KubernetesPatch(stack, 'cnipatch', {
35
+ cluster,
36
+ resourceName: 'installation/default',
37
+ applyPatch: [{ op: 'replace', path: '/spec/cni', value: { type: 'Calico' } }],
38
+ restorePatch: [{ op: 'remove', path: '/spec/cni' }],
39
+ patchType: eks.PatchType.JSON,
40
+ });
41
+
42
+ cnipatch.node.addDependency(calico);
43
+
44
+ new IntegTest(app, 'aws-cdk-eks-custom-addons', {
45
+ testCases: [stack],
46
+ // Test includes assets that are updated weekly. If not disabled, the upgrade PR will fail.
47
+ diffAssets: false,
48
+ });
@@ -199,6 +199,7 @@ the name `Namespace/MetricName`.
199
199
 
200
200
  You can expose a metric on a metric filter by calling the `MetricFilter.metric()` API.
201
201
  This has a default of `statistic = 'avg'` if the statistic is not set in the `props`.
202
+ Additionally, if the metric filter was created with a dimension map, those dimensions will be included in the metric.
202
203
 
203
204
  ```ts
204
205
  declare const logGroup: logs.LogGroup;
@@ -0,0 +1,47 @@
1
+ import { App, Stack, StackProps } from 'aws-cdk-lib';
2
+ import { FilterPattern, LogGroup, MetricFilter } from 'aws-cdk-lib/aws-logs';
3
+ import { Dashboard, GraphWidget } from 'aws-cdk-lib/aws-cloudwatch';
4
+ import { IntegTest } from '@aws-cdk/integ-tests-alpha';
5
+
6
+ class ExposeMetricWithDimensions extends Stack {
7
+ constructor(scope: App, id: string, props?: StackProps) {
8
+ super(scope, id, props);
9
+
10
+ const logGroup = new LogGroup(this, 'LogGroup');
11
+
12
+ // Create a metric filter with dimensions
13
+ const mf = new MetricFilter(this, 'MetricFilter', {
14
+ logGroup,
15
+ metricName: 'testName',
16
+ metricNamespace: 'testNamespace',
17
+ filterPattern: FilterPattern.exists('$.latency'),
18
+ metricValue: '$.latency',
19
+ dimensions: {
20
+ Foo: 'Bar',
21
+ Bar: 'Baz',
22
+ },
23
+ });
24
+
25
+ // Expose the metric with dimensions
26
+ const metric = mf.metric();
27
+
28
+ new Dashboard(this, 'Dashboard', {
29
+ dashboardName: 'ExposeMetricWithDimensionsDashboard',
30
+ widgets: [[
31
+ new GraphWidget({
32
+ title: 'Latency with Dimensions',
33
+ left: [metric],
34
+ }),
35
+ ]],
36
+ });
37
+ }
38
+ }
39
+
40
+ const app = new App();
41
+ const stack = new ExposeMetricWithDimensions(app, 'aws-cdk-expose-metric-with-dimensions-integ');
42
+
43
+ new IntegTest(stack, 'ExposeMetricWithDimensionsTest', {
44
+ testCases: [stack],
45
+ });
46
+
47
+ app.synth();
@@ -1,7 +1,7 @@
1
1
  import { App, RemovalPolicy, Stack, StackProps } from 'aws-cdk-lib';
2
2
  import { Construct } from 'constructs';
3
3
  import * as opensearch from 'aws-cdk-lib/aws-opensearchservice';
4
- import { EbsDeviceVolumeType } from 'aws-cdk-lib/aws-ec2';
4
+ import { EbsDeviceVolumeType, SubnetType } from 'aws-cdk-lib/aws-ec2';
5
5
  import { IntegTest } from '@aws-cdk/integ-tests-alpha';
6
6
 
7
7
  class TestStack extends Stack {
@@ -19,6 +19,21 @@ class TestStack extends Stack {
19
19
  throughput: 125,
20
20
  iops: 3000,
21
21
  },
22
+ zoneAwareness: {
23
+ enabled: true,
24
+ availabilityZoneCount: 3,
25
+ },
26
+ vpcSubnets: [
27
+ { subnetType: SubnetType.PRIVATE_WITH_EGRESS },
28
+ ],
29
+ capacity: {
30
+ dataNodeInstanceType: 'm7g.medium.search',
31
+ dataNodes: 3,
32
+ // Add dedicated master node - required for multi-AZ with standby
33
+ // m7g.large.search has 8GB RAM (minimum for 30 nodes/15K shards)
34
+ masterNodeInstanceType: 'm7g.large.search',
35
+ masterNodes: 3,
36
+ },
22
37
  };
23
38
 
24
39
  new opensearch.Domain(this, 'Domain', domainProps);
@@ -0,0 +1,54 @@
1
+ import { App, RemovalPolicy, Stack, StackProps } from 'aws-cdk-lib';
2
+ import { Construct } from 'constructs';
3
+ import * as opensearch from 'aws-cdk-lib/aws-opensearchservice';
4
+ import { ExpectedResult, IntegTest } from '@aws-cdk/integ-tests-alpha';
5
+
6
+ /**
7
+ * After deploying this test, you can verify that the OpenSearch domain using:
8
+ *
9
+ * $ aws es describe-elasticsearch-domain \
10
+ * --region us-east-1 \
11
+ * --domain-name DOMAIN_NAME \
12
+ * --query 'DomainStatus.DomainEndpointOptions' \
13
+ * --output json
14
+ */
15
+
16
+ class TestStack extends Stack {
17
+ public readonly domain: opensearch.Domain;
18
+
19
+ constructor(scope: Construct, id: string, props?: StackProps) {
20
+ super(scope, id, props);
21
+
22
+ // deploy opensearch domain with minimal configuration
23
+ const domainProps: opensearch.DomainProps = {
24
+ version: opensearch.EngineVersion.OPENSEARCH_2_17,
25
+ removalPolicy: RemovalPolicy.DESTROY,
26
+ capacity: {
27
+ multiAzWithStandbyEnabled: false,
28
+ },
29
+ enforceHttps: true,
30
+ };
31
+
32
+ this.domain = new opensearch.Domain(this, 'domain', domainProps);
33
+ }
34
+ }
35
+
36
+ const app = new App();
37
+ const stack = new TestStack(app, 'cdk-integ-opensearch-https');
38
+
39
+ const integ = new IntegTest(app, 'integ-openseach-https', { testCases: [stack] });
40
+
41
+ // Assert TLS security policy using AwsApiCall
42
+ const describeResponse = integ.assertions.awsApiCall('OpenSearch', 'describeDomain', {
43
+ DomainName: stack.domain.domainName,
44
+ });
45
+
46
+ // Verify domain endpoint configuration
47
+ describeResponse.expect(ExpectedResult.objectLike({
48
+ DomainStatus: {
49
+ DomainEndpointOptions: {
50
+ EnforceHTTPS: true,
51
+ TLSSecurityPolicy: 'Policy-Min-TLS-1-2-2019-07',
52
+ },
53
+ },
54
+ }));
@@ -280,9 +280,20 @@ things.
280
280
  > *Info* More complete details can be found [in the docs](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless-v2.setting-capacity.html#aurora-serverless-v2-examples-setting-capacity-range-for-cluster)
281
281
 
282
282
  You can also set minimum capacity to zero ACUs and automatically pause,
283
- if they don't have any connections initiated by user activity within a specified time period.
283
+ if they don't have any connections initiated by user activity within a time period specified by `serverlessV2AutoPauseDuration` (300 seconds by default).
284
284
  For more information, see [Scaling to Zero ACUs with automatic pause and resume for Aurora Serverless v2](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless-v2-auto-pause.html).
285
285
 
286
+ ```ts
287
+ declare const vpc: ec2.Vpc;
288
+ const cluster = new rds.DatabaseCluster(this, 'Database', {
289
+ engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_3_08_0 }),
290
+ writer: rds.ClusterInstance.serverlessV2('writer'),
291
+ serverlessV2MinCapacity: 0,
292
+ serverlessV2AutoPauseDuration: Duration.hours(1),
293
+ vpc,
294
+ });
295
+ ```
296
+
286
297
  Another way that you control the capacity/scaling of your serverless v2 reader
287
298
  instances is based on the [promotion tier](https://aws.amazon.com/blogs/aws/additional-failover-control-for-amazon-aurora/)
288
299
  which can be between 0-15. Any serverless v2 instance in the 0-1 tiers will scale alongside the
@@ -588,6 +599,18 @@ new rds.DatabaseInstanceReadReplica(this, 'ReadReplica', {
588
599
  });
589
600
  ```
590
601
 
602
+ Or you can [restore a DB instance from a Multi-AZ DB cluster snapshot](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_RestoreFromMultiAZDBClusterSnapshot.html)
603
+
604
+ ```ts
605
+ declare const vpc: ec2.Vpc;
606
+
607
+ new rds.DatabaseInstanceFromSnapshot(this, 'Instance', {
608
+ clusterSnapshotIdentifier: 'my-cluster-snapshot',
609
+ engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
610
+ vpc,
611
+ });
612
+ ```
613
+
591
614
  Automatic backups of read replica instances are only supported for MySQL and MariaDB. By default,
592
615
  automatic backups are disabled for read replicas and can only be enabled (using `backupRetention`)
593
616
  if also enabled on the source instance.
@@ -961,7 +984,7 @@ proxy.grantConnect(role, 'admin'); // Grant the role connection access to the DB
961
984
  See <https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.DBAccounts.html> for setup instructions.
962
985
 
963
986
  To specify the details of authentication used by a proxy to log in as a specific database
964
- user use the `clientPasswordAuthType` property:
987
+ user use the `clientPasswordAuthType` property:
965
988
 
966
989
  ```ts
967
990
  declare const vpc: ec2.Vpc;
@@ -0,0 +1,27 @@
1
+ import { IntegTest } from '@aws-cdk/integ-tests-alpha';
2
+ import { App, Duration, RemovalPolicy, Stack, StackProps } from 'aws-cdk-lib';
3
+ import { Vpc } from 'aws-cdk-lib/aws-ec2';
4
+ import * as rds from 'aws-cdk-lib/aws-rds';
5
+ import { ClusterInstance } from 'aws-cdk-lib/aws-rds';
6
+ import { Construct } from 'constructs';
7
+
8
+ export class TestStack extends Stack {
9
+ constructor(scope: Construct, id: string, props?: StackProps) {
10
+ super(scope, id, props);
11
+ const vpc = new Vpc(this, 'Integ-VPC');
12
+ new rds.DatabaseCluster(this, 'Integ-Cluster', {
13
+ engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_3_08_0 }),
14
+ serverlessV2MaxCapacity: 1,
15
+ serverlessV2MinCapacity: 0,
16
+ serverlessV2AutoPauseDuration: Duration.hours(1),
17
+ writer: ClusterInstance.serverlessV2('writer'),
18
+ removalPolicy: RemovalPolicy.DESTROY,
19
+ vpc: vpc,
20
+ });
21
+ }
22
+ }
23
+
24
+ const app = new App();
25
+ new IntegTest(app, 'integ-test-autopause', {
26
+ testCases: [new TestStack(app, 'integ-aurora-serverlessv2-cluster-autopause')],
27
+ });
@@ -0,0 +1,23 @@
1
+ import * as ec2 from 'aws-cdk-lib/aws-ec2';
2
+ import { App, RemovalPolicy, Stack } from 'aws-cdk-lib';
3
+ import * as rds from 'aws-cdk-lib/aws-rds';
4
+ import { IntegTest } from '@aws-cdk/integ-tests-alpha';
5
+
6
+ const app = new App();
7
+ const stack = new Stack(app, 'cdk-instance-from-cluster-snapshot');
8
+
9
+ const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2, natGateways: 1, restrictDefaultSecurityGroup: false });
10
+
11
+ // For simplicity, get a public snapshot
12
+ new rds.DatabaseInstanceFromSnapshot(stack, 'FromSnapshot', {
13
+ clusterSnapshotIdentifier: 'arn:aws:rds:us-east-1:703671916075:cluster-snapshot:test-cluster-snpa',
14
+ allocatedStorage: 200,
15
+ engine: rds.DatabaseInstanceEngine.mysql({ version: rds.MysqlEngineVersion.VER_8_0_40 }),
16
+ instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.MEDIUM),
17
+ vpc,
18
+ removalPolicy: RemovalPolicy.DESTROY,
19
+ });
20
+
21
+ new IntegTest(app, 'cdk-instance-from-cluster-snapshot-test', {
22
+ testCases: [stack],
23
+ });
@@ -57,6 +57,22 @@ This method uses AWS API calls to lookup the value from SSM during synthesis.
57
57
  const stringValue = ssm.StringParameter.valueFromLookup(this, '/My/Public/Parameter');
58
58
  ```
59
59
 
60
+ The result of the `StringParameter.valueFromLookup()` operation will be written to a file
61
+ called `cdk.context.json`. You must commit this file to source control so
62
+ that the lookup values are available in non-privileged environments such
63
+ as CI build steps, and to ensure your template builds are repeatable.
64
+
65
+ To customize the cache key, use the `additionalCacheKey` property of the `options` parameter.
66
+ This allows you to have multiple lookups with the same parameters
67
+ cache their values separately. This can be useful if you want to
68
+ scope the context variable to a construct (ie, using `additionalCacheKey: this.node.path`),
69
+ so that if the value in the cache needs to be updated, it does not need to be updated
70
+ for all constructs at the same time.
71
+
72
+ ```ts
73
+ const stringValue = ssm.StringParameter.valueFromLookup(this, '/My/Public/Parameter', undefined, { additionalCacheKey: this.node.path });
74
+ ```
75
+
60
76
  When using `valueFromLookup` an initial value of 'dummy-value-for-${parameterName}'
61
77
  (`dummy-value-for-/My/Public/Parameter` in the above example)
62
78
  is returned prior to the lookup being performed. This can lead to errors if you are using this
@@ -840,6 +840,27 @@ const definition = choice
840
840
  map.itemProcessor(definition);
841
841
  ```
842
842
 
843
+ When using `JSONata`, the `itemSelector` property in a Map state can be specified in one of two ways. You can provide a valid JSON object containing JSONata expressions for each value:
844
+
845
+ ```ts
846
+ const map = new sfn.Map(this, 'Map State', {
847
+ maxConcurrency: 1,
848
+ itemSelector: {
849
+ id: '{% $states.context.Map.Item.Value.id %}',
850
+ status: '{% $states.context.Map.Item.Value.status %}',
851
+ }
852
+ });
853
+ ```
854
+
855
+ Alternatively, you can use the `jsonataItemSelector` field to directly supply a JSONata string that evaluates to a complete JSON object:
856
+
857
+ ```ts
858
+ const map = new sfn.Map(this, 'Map State', {
859
+ maxConcurrency: 1,
860
+ jsonataItemSelector: '{% {\"id\": $states.input.id, \"status\": $states.input.status} %}'
861
+ });
862
+ ```
863
+
843
864
  To define a distributed `Map` state set `itemProcessors` mode to `ProcessorMode.DISTRIBUTED`.
844
865
  An `executionType` must be specified for the distributed `Map` workflow.
845
866
 
@@ -0,0 +1,36 @@
1
+ import { IntegTest, ExpectedResult } from '@aws-cdk/integ-tests-alpha';
2
+ import * as cdk from 'aws-cdk-lib';
3
+ import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
4
+
5
+ /**
6
+ * Stack verification steps:
7
+ *
8
+ * -- aws stepfunctions describe-state-machine --state-machine-arn <stack-output> has a status of `ACTIVE`
9
+ */
10
+ const app = new cdk.App();
11
+ const stack = new cdk.Stack(app, 'cdk-stepfunctions-map-jsonata-itemselector-stack');
12
+
13
+ const map = new sfn.Map(stack, 'Map', {
14
+ queryLanguage: sfn.QueryLanguage.JSONATA,
15
+ stateName: 'My-Map-State',
16
+ maxConcurrency: 1,
17
+ jsonataItemSelector: '{% {\"foo\": \"foo\", \"bar\": $states.input.bar} %}',
18
+ });
19
+ map.itemProcessor(new sfn.Pass(stack, 'Pass State'));
20
+
21
+ const sm = new sfn.StateMachine(stack, 'StateMachine', {
22
+ definition: map,
23
+ timeout: cdk.Duration.seconds(30),
24
+ });
25
+
26
+ const testCase = new IntegTest(app, 'cdk-stepfunctions-map-itemselector-integ', {
27
+ testCases: [stack],
28
+ });
29
+
30
+ testCase.assertions.awsApiCall('StepFunctions', 'describeStateMachine', {
31
+ stateMachineArn: sm.stateMachineArn,
32
+ }).expect(ExpectedResult.objectLike({
33
+ status: 'ACTIVE',
34
+ }));
35
+
36
+ app.synth();
@@ -1,119 +1,112 @@
1
- import { Code, Function } from 'aws-cdk-lib/aws-lambda';
2
- import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
3
- import * as cdk from 'aws-cdk-lib';
4
- import { LambdaInvoke } from 'aws-cdk-lib/aws-stepfunctions-tasks';
1
+ import * as path from 'path';
5
2
  import { IntegTest, ExpectedResult } from '@aws-cdk/integ-tests-alpha';
6
- import { STANDARD_NODEJS_RUNTIME } from '../../../config';
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';
6
+ import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
7
+ import * as lambda from 'aws-cdk-lib/aws-lambda-nodejs';
8
+ import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks';
9
+ import { password, username } from './my-lambda-handler';
7
10
 
8
11
  /*
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`.
12
+ * Creates an API Gateway instance with a GET method and mock integration,
13
+ * secured with basic auth. It then creates a matching Connection and uses it
14
+ * in a state machine with a task state to invoke the endpoint.
16
15
  *
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`
16
+ * Stack verification steps :
17
+ * * aws stepfunctions start-execution --state-machine-arn <deployed state machine arn> : should return execution arn
18
+ * * aws stepfunctions describe-execution --execution-arn <execution-arn generated before> : should return status as 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-lambda-invoke-jsonata-integ');
25
+ const stack = new cdk.Stack(app, 'aws-stepfunctions-tasks-http-invoke-integ');
26
26
 
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',
27
+ const authorizerHandler = new lambda.NodejsFunction(stack, 'AuthorizerHandler', {
28
+ entry: path.resolve(__dirname, 'my-lambda-handler', 'index.ts'),
29
+ handler: 'handler',
37
30
  });
38
31
 
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 %}',
52
- }),
53
- outputs: '{% $states.result.Payload %}',
32
+ const authorizer = new apigateway.TokenAuthorizer(stack, 'Authorizer', {
33
+ handler: authorizerHandler,
34
+ identitySource: 'method.request.header.Authorization',
35
+ resultsCacheTtl: cdk.Duration.seconds(0),
54
36
  });
55
37
 
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
- });
38
+ const api = new apigateway.RestApi(stack, 'IntegRestApi');
71
39
 
72
- const checkJobState = LambdaInvoke.jsonata(stack, 'Check the job state', {
73
- lambdaFunction: checkJobStateLambda,
74
- outputs: {
75
- status: '{% $states.result.Payload.status %}',
40
+ api.root.addResource('test').addMethod(
41
+ 'GET',
42
+ new apigateway.MockIntegration({
43
+ integrationResponses: [
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
+ ],
76
63
  },
77
- });
64
+ );
78
65
 
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',
66
+ const connection = new events.Connection(stack, 'Connection', {
67
+ authorization: events.Authorization.basic(username, cdk.SecretValue.unsafePlainText(password)),
83
68
  });
84
- const finalStatus = sfn.Pass.jsonata(stack, 'Final step');
85
69
 
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
- );
70
+ const httpInvokeTask = tasks.HttpInvoke.jsonata(stack, 'Invoke HTTP Endpoint', {
71
+ apiRoot: api.urlForPath('/'),
72
+ apiEndpoint: sfn.TaskInput.fromText('{% $states.input.apiEndpoint %}'),
73
+ connection,
74
+ method: sfn.TaskInput.fromText('GET'),
75
+ outputs: {
76
+ ResponseBody: '{% $states.result.ResponseBody %}',
77
+ },
78
+ });
93
79
 
94
80
  const sm = new sfn.StateMachine(stack, 'StateMachine', {
95
- definition: chain,
81
+ definition: httpInvokeTask,
96
82
  timeout: cdk.Duration.seconds(30),
97
83
  });
98
84
 
99
- new cdk.CfnOutput(stack, 'stateMachineArn', {
100
- value: sm.stateMachineArn,
101
- });
102
-
103
- const integ = new IntegTest(app, 'IntegTest', {
85
+ const testCase = new IntegTest(app, 'HttpInvokeTest', {
104
86
  testCases: [stack],
105
87
  });
106
- const res = integ.assertions.awsApiCall('@aws-sdk/client-sfn', 'StartExecution', {
88
+
89
+ // Start an execution
90
+ const start = testCase.assertions.awsApiCall('@aws-sdk/client-sfn', 'StartExecution', {
107
91
  stateMachineArn: sm.stateMachineArn,
92
+ input: JSON.stringify({
93
+ apiEndpoint: '/test',
94
+ }),
108
95
  });
109
- const executionArn = res.getAttString('executionArn');
110
- integ.assertions.awsApiCall('@aws-sdk/client-sfn', 'DescribeExecution', {
111
- executionArn,
112
- }).expect(ExpectedResult.objectLike({
113
- status: 'SUCCEEDED',
114
- })).waitForAssertions({
115
- totalTimeout: cdk.Duration.seconds(10),
116
- interval: cdk.Duration.seconds(3),
96
+
97
+ // describe the results of the execution
98
+ const describe = testCase.assertions.awsApiCall('@aws-sdk/client-sfn', 'DescribeExecution', {
99
+ executionArn: start.getAttString('executionArn'),
117
100
  });
118
101
 
102
+ // assert the results
103
+ describe.expect(ExpectedResult.objectLike({
104
+ status: 'SUCCEEDED',
105
+ output: JSON.stringify({
106
+ ResponseBody: {
107
+ message: 'Hello, tester!',
108
+ },
109
+ }),
110
+ }));
111
+
119
112
  app.synth();