From 460f9b226bd9ebe380953017eb6568da268ab4c6 Mon Sep 17 00:00:00 2001 From: NetaNir Date: Fri, 16 Apr 2021 13:37:00 -0700 Subject: [PATCH 01/11] feat(stepfunction-tasks/route53-targets): add apigwv2 interface to the integration packages --- .../lib/api-gatewayv2-domain-name.ts | 18 +++++++++++++++++- .../@aws-cdk/aws-route53-targets/package.json | 3 +-- .../lib/apigateway/call-http-api.ts | 14 ++++++++++++-- .../aws-stepfunctions-tasks/package.json | 6 ++---- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/packages/@aws-cdk/aws-route53-targets/lib/api-gatewayv2-domain-name.ts b/packages/@aws-cdk/aws-route53-targets/lib/api-gatewayv2-domain-name.ts index b78078fca525a..8e942bf71e0cc 100644 --- a/packages/@aws-cdk/aws-route53-targets/lib/api-gatewayv2-domain-name.ts +++ b/packages/@aws-cdk/aws-route53-targets/lib/api-gatewayv2-domain-name.ts @@ -5,7 +5,7 @@ import * as route53 from '@aws-cdk/aws-route53'; * Defines an API Gateway V2 domain name as the alias target. */ export class ApiGatewayv2Domain implements route53.IAliasRecordTarget { - constructor(private readonly domainName: apigv2.IDomainName) { } + constructor(private readonly domainName: ApiGatewayDomainName) { } public bind(_record: route53.IRecordSet): route53.AliasRecordTargetConfig { return { @@ -14,3 +14,19 @@ export class ApiGatewayv2Domain implements route53.IAliasRecordTarget { }; } } + +/** + * Represents an APIGatewayV2 DomainName + */ +export interface ApiGatewayDomainName { + /** + * The region-specific Amazon Route 53 Hosted Zone ID of the regional endpoint. + */ + readonly regionalHostedZoneId: string; + + /** + * The domain name associated with the regional endpoint for this custom domain name. + */ + readonly regionalDomainName: string; + +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-route53-targets/package.json b/packages/@aws-cdk/aws-route53-targets/package.json index aa93fb6d5955a..47ea2969a1e93 100644 --- a/packages/@aws-cdk/aws-route53-targets/package.json +++ b/packages/@aws-cdk/aws-route53-targets/package.json @@ -64,6 +64,7 @@ "devDependencies": { "@aws-cdk/aws-certificatemanager": "0.0.0", "@aws-cdk/aws-lambda": "0.0.0", + "@aws-cdk/aws-apigatewayv2": "0.0.0", "cdk-build-tools": "0.0.0", "cdk-integ-tools": "0.0.0", "cfn2ts": "0.0.0", @@ -73,7 +74,6 @@ }, "dependencies": { "@aws-cdk/aws-apigateway": "0.0.0", - "@aws-cdk/aws-apigatewayv2": "0.0.0", "@aws-cdk/aws-cloudfront": "0.0.0", "@aws-cdk/aws-cognito": "0.0.0", "@aws-cdk/aws-ec2": "0.0.0", @@ -90,7 +90,6 @@ "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { "@aws-cdk/aws-apigateway": "0.0.0", - "@aws-cdk/aws-apigatewayv2": "0.0.0", "@aws-cdk/aws-cloudfront": "0.0.0", "@aws-cdk/aws-cognito": "0.0.0", "@aws-cdk/aws-ec2": "0.0.0", diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts index e06e46c2580b0..34b85719ae487 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts @@ -2,7 +2,7 @@ import * as apigatewayv2 from '@aws-cdk/aws-apigatewayv2'; import * as iam from '@aws-cdk/aws-iam'; import * as sfn from '@aws-cdk/aws-stepfunctions'; import * as cdk from '@aws-cdk/core'; -import { Construct } from 'constructs'; +import { Construct, IConstruct } from 'constructs'; import { CallApiGatewayEndpointBase } from './base'; import { CallApiGatewayEndpointBaseProps } from './base-types'; @@ -13,7 +13,7 @@ export interface CallApiGatewayHttpApiEndpointProps extends CallApiGatewayEndpoi /** * API to call */ - readonly api: apigatewayv2.IHttpApi; + readonly api: IApiGatewayV2HttpApi; /** * Name of the stage where the API is deployed to in API Gateway @@ -22,6 +22,16 @@ export interface CallApiGatewayHttpApiEndpointProps extends CallApiGatewayEndpoi readonly stageName?: string; } +/** + * An APIGateWayV2 Http API resource representation + */ +export interface IApiGatewayV2HttpApi extends IConstruct { + /** + * The identifier of this API Gateway HTTP API. + */ + readonly apiId: string; +} + /** * Call HTTP API endpoint as a Task * diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/package.json b/packages/@aws-cdk/aws-stepfunctions-tasks/package.json index 23724cc057666..8ee8228cabd42 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/package.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/package.json @@ -68,14 +68,14 @@ "@aws-cdk/aws-glue": "0.0.0", "cdk-build-tools": "0.0.0", "cdk-integ-tools": "0.0.0", + "@aws-cdk/aws-apigatewayv2": "0.0.0", + "@aws-cdk/aws-apigatewayv2-integrations": "0.0.0", "jest": "^26.6.3", "pkglint": "0.0.0", "@aws-cdk/assert-internal": "0.0.0" }, "dependencies": { "@aws-cdk/aws-apigateway": "0.0.0", - "@aws-cdk/aws-apigatewayv2": "0.0.0", - "@aws-cdk/aws-apigatewayv2-integrations": "0.0.0", "@aws-cdk/aws-batch": "0.0.0", "@aws-cdk/aws-cloudwatch": "0.0.0", "@aws-cdk/aws-codebuild": "0.0.0", @@ -99,8 +99,6 @@ "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { "@aws-cdk/aws-apigateway": "0.0.0", - "@aws-cdk/aws-apigatewayv2": "0.0.0", - "@aws-cdk/aws-apigatewayv2-integrations": "0.0.0", "@aws-cdk/aws-batch": "0.0.0", "@aws-cdk/aws-cloudwatch": "0.0.0", "@aws-cdk/aws-codebuild": "0.0.0", From b96d79aa8df6b263bb47bcc30b11139dd095d52d Mon Sep 17 00:00:00 2001 From: NetaNir Date: Fri, 16 Apr 2021 16:24:29 -0700 Subject: [PATCH 02/11] remove imports --- .../aws-route53-targets/lib/api-gatewayv2-domain-name.ts | 1 - .../aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/@aws-cdk/aws-route53-targets/lib/api-gatewayv2-domain-name.ts b/packages/@aws-cdk/aws-route53-targets/lib/api-gatewayv2-domain-name.ts index 8e942bf71e0cc..84472a3772b0e 100644 --- a/packages/@aws-cdk/aws-route53-targets/lib/api-gatewayv2-domain-name.ts +++ b/packages/@aws-cdk/aws-route53-targets/lib/api-gatewayv2-domain-name.ts @@ -1,4 +1,3 @@ -import * as apigv2 from '@aws-cdk/aws-apigatewayv2'; import * as route53 from '@aws-cdk/aws-route53'; /** diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts index 34b85719ae487..fed72453405da 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts @@ -1,4 +1,3 @@ -import * as apigatewayv2 from '@aws-cdk/aws-apigatewayv2'; import * as iam from '@aws-cdk/aws-iam'; import * as sfn from '@aws-cdk/aws-stepfunctions'; import * as cdk from '@aws-cdk/core'; From 5dc9e73382d64f6654954e2b5a6e422d18ec1fda Mon Sep 17 00:00:00 2001 From: NetaNir Date: Fri, 16 Apr 2021 20:05:59 -0700 Subject: [PATCH 03/11] allow breaking changes --- allowed-breaking-changes.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/allowed-breaking-changes.txt b/allowed-breaking-changes.txt index 0f5c6dc507097..ef15a1505ec2f 100644 --- a/allowed-breaking-changes.txt +++ b/allowed-breaking-changes.txt @@ -61,3 +61,7 @@ weakened:@aws-cdk/cloud-assembly-schema.FileSource # These are fine, since they shouldn't be widely used. weakened:@aws-cdk/core.FileAssetLocation weakened:@aws-cdk/aws-events.RuleTargetConfig + +# Move the interface to the integration package to break dependencies between stable and experimental +strengthened:@aws-cdk/aws-stepfunctions-tasks.CallApiGatewayHttpApiEndpointProps +incompatible-argument:@aws-cdk/aws-route53-targets.ApiGatewayv2Domain. From 173516f7655ab7ce3e00a2ab32e67d9e15049bcd Mon Sep 17 00:00:00 2001 From: NetaNir Date: Sun, 18 Apr 2021 02:27:56 -0700 Subject: [PATCH 04/11] untype all the things --- allowed-breaking-changes.txt | 11 +- .../@aws-cdk/aws-events-targets/lib/batch.ts | 20 +-- .../test/batch/batch.test.ts | 2 +- .../test/batch/integ.job-definition-events.ts | 4 +- .../aws-lambda-event-sources/README.md | 7 +- .../aws-lambda-event-sources/lib/kafka.ts | 9 +- .../aws-lambda-event-sources/package.json | 2 - .../test/test.kafka.ts | 9 +- .../@aws-cdk/aws-route53-targets/README.md | 3 +- .../lib/api-gatewayv2-domain-name.ts | 28 ++--- .../test/apigatewayv2-target.test.ts | 10 +- .../aws-stepfunctions-tasks/README.md | 115 +++++++++--------- .../lib/apigateway/call-http-api.ts | 31 ++--- .../lib/batch/run-batch-job.ts | 15 ++- .../lib/batch/submit-job.ts | 15 ++- .../aws-stepfunctions-tasks/package.json | 9 +- .../test/apigateway/call-http-api.test.ts | 12 +- .../test/apigateway/integ.call-http-api.ts | 3 +- .../test/batch/integ.run-batch-job.ts | 4 +- .../test/batch/integ.submit-job.ts | 4 +- .../test/batch/run-batch-job.test.ts | 44 +++---- .../test/batch/submit-job.test.ts | 48 ++++---- 22 files changed, 201 insertions(+), 204 deletions(-) diff --git a/allowed-breaking-changes.txt b/allowed-breaking-changes.txt index ef15a1505ec2f..6c0a5aa9fd2ef 100644 --- a/allowed-breaking-changes.txt +++ b/allowed-breaking-changes.txt @@ -62,6 +62,13 @@ weakened:@aws-cdk/cloud-assembly-schema.FileSource weakened:@aws-cdk/core.FileAssetLocation weakened:@aws-cdk/aws-events.RuleTargetConfig -# Move the interface to the integration package to break dependencies between stable and experimental +# replace interface with untyped properties to order to break stable to experimental dependencies +removed:@aws-cdk/aws-stepfunctions-tasks.CallApiGatewayHttpApiEndpointProps.api strengthened:@aws-cdk/aws-stepfunctions-tasks.CallApiGatewayHttpApiEndpointProps -incompatible-argument:@aws-cdk/aws-route53-targets.ApiGatewayv2Domain. +removed:@aws-cdk/aws-route53-targets.ApiGatewayv2Domain. +removed:@aws-cdk/aws-stepfunctions-tasks.RunBatchJobProps.jobDefinition +removed:@aws-cdk/aws-stepfunctions-tasks.RunBatchJobProps.jobDefinition +removed:@aws-cdk/aws-stepfunctions-tasks.RunBatchJobProps.jobQueue +removed:@aws-cdk/aws-stepfunctions-tasks.BatchSubmitJobProps.jobQueue +removed:@aws-cdk/aws-stepfunctions-tasks.BatchSubmitJobProps.jobDefinition +strengthened:@aws-cdk/aws-stepfunctions-tasks.BatchSubmitJobProps diff --git a/packages/@aws-cdk/aws-events-targets/lib/batch.ts b/packages/@aws-cdk/aws-events-targets/lib/batch.ts index 0d3e3c5b8409f..95d69a1c35468 100644 --- a/packages/@aws-cdk/aws-events-targets/lib/batch.ts +++ b/packages/@aws-cdk/aws-events-targets/lib/batch.ts @@ -1,7 +1,6 @@ -import * as batch from '@aws-cdk/aws-batch'; import * as events from '@aws-cdk/aws-events'; import * as iam from '@aws-cdk/aws-iam'; -import { Names } from '@aws-cdk/core'; +import { Names, Stack } from '@aws-cdk/core'; import { singletonEventRole } from './util'; /** @@ -48,8 +47,9 @@ export interface BatchJobProps { */ export class BatchJob implements events.IRuleTarget { constructor( - private readonly jobQueue: batch.IJobQueue, - private readonly jobDefinition: batch.IJobDefinition, + private readonly jobQueueArn: string, + private readonly jobDefinitionArn: string, + private readonly jobStack: Stack, private readonly props: BatchJobProps = {}, ) { } @@ -59,27 +59,27 @@ export class BatchJob implements events.IRuleTarget { */ public bind(rule: events.IRule, _id?: string): events.RuleTargetConfig { const batchParameters: events.CfnRule.BatchParametersProperty = { - jobDefinition: this.jobDefinition.jobDefinitionArn, + jobDefinition: this.jobDefinitionArn, jobName: this.props.jobName ?? Names.nodeUniqueId(rule.node), arrayProperties: this.props.size ? { size: this.props.size } : undefined, retryStrategy: this.props.attempts ? { attempts: this.props.attempts } : undefined, }; return { - arn: this.jobQueue.jobQueueArn, + arn: this.jobQueueArn, // When scoping resource-level access for job submission, you must provide both job queue and job definition resource types. // https://docs.aws.amazon.com/batch/latest/userguide/ExamplePolicies_BATCH.html#iam-example-restrict-job-def - role: singletonEventRole(this.jobDefinition, [ + role: singletonEventRole(this.jobStack, [ new iam.PolicyStatement({ actions: ['batch:SubmitJob'], resources: [ - this.jobDefinition.jobDefinitionArn, - this.jobQueue.jobQueueArn, + this.jobDefinitionArn, + this.jobQueueArn, ], }), ]), input: this.props.event, - targetResource: this.jobQueue, + targetResource: this.jobStack, batchParameters, }; } diff --git a/packages/@aws-cdk/aws-events-targets/test/batch/batch.test.ts b/packages/@aws-cdk/aws-events-targets/test/batch/batch.test.ts index bfa08fe3f4f60..ae8d62d0949b4 100644 --- a/packages/@aws-cdk/aws-events-targets/test/batch/batch.test.ts +++ b/packages/@aws-cdk/aws-events-targets/test/batch/batch.test.ts @@ -28,7 +28,7 @@ test('use aws batch job as an eventrule target', () => { }); // WHEN - rule.addTarget(new targets.BatchJob(jobQueue, jobDefinition)); + rule.addTarget(new targets.BatchJob(jobQueue.jobQueueArn, jobDefinition.jobDefinitionArn, Stack.of(jobDefinition))); // THEN expect(stack).to(haveResource('AWS::Events::Rule', { diff --git a/packages/@aws-cdk/aws-events-targets/test/batch/integ.job-definition-events.ts b/packages/@aws-cdk/aws-events-targets/test/batch/integ.job-definition-events.ts index d09960c142971..449c2b3756e14 100644 --- a/packages/@aws-cdk/aws-events-targets/test/batch/integ.job-definition-events.ts +++ b/packages/@aws-cdk/aws-events-targets/test/batch/integ.job-definition-events.ts @@ -27,11 +27,11 @@ const job = new batch.JobDefinition(stack, 'MyJob', { const timer = new events.Rule(stack, 'Timer', { schedule: events.Schedule.rate(cdk.Duration.minutes(1)), }); -timer.addTarget(new targets.BatchJob(queue, job)); +timer.addTarget(new targets.BatchJob(queue.jobQueueArn, job.jobDefinitionArn, cdk.Stack.of(job))); const timer2 = new events.Rule(stack, 'Timer2', { schedule: events.Schedule.rate(cdk.Duration.minutes(2)), }); -timer2.addTarget(new targets.BatchJob(queue, job)); +timer2.addTarget(new targets.BatchJob(queue.jobQueueArn, job.jobDefinitionArn, cdk.Stack.of(job))); app.synth(); diff --git a/packages/@aws-cdk/aws-lambda-event-sources/README.md b/packages/@aws-cdk/aws-lambda-event-sources/README.md index 55cd7e864125a..d770e10943c22 100644 --- a/packages/@aws-cdk/aws-lambda-event-sources/README.md +++ b/packages/@aws-cdk/aws-lambda-event-sources/README.md @@ -225,9 +225,8 @@ import * as msk from '@aws-cdk/aws-lambda'; import { Secret } from '@aws-cdk/aws-secretmanager'; import { ManagedKafkaEventSource } from '@aws-cdk/aws-lambda-event-sources'; -// Your MSK cluster -const cluster = msk.Cluster.fromClusterArn(this, 'Cluster', - 'arn:aws:kafka:us-east-1:0123456789019:cluster/SalesCluster/abcd1234-abcd-cafe-abab-9876543210ab-4'); +// Your MSK cluster arn +const cluster = 'arn:aws:kafka:us-east-1:0123456789019:cluster/SalesCluster/abcd1234-abcd-cafe-abab-9876543210ab-4'; // The Kafka topic you want to subscribe to const topic = 'some-cool-topic' @@ -237,7 +236,7 @@ const topic = 'some-cool-topic' const secret = new Secret(this, 'Secret', { secretName: 'AmazonMSK_KafkaSecret' }); myFunction.addEventSource(new ManagedKafkaEventSource({ - cluster: cluster, + clusterArn, topic: topic, secret: secret, batchSize: 100, // default diff --git a/packages/@aws-cdk/aws-lambda-event-sources/lib/kafka.ts b/packages/@aws-cdk/aws-lambda-event-sources/lib/kafka.ts index f0782964d93ce..e4892b41abf6b 100644 --- a/packages/@aws-cdk/aws-lambda-event-sources/lib/kafka.ts +++ b/packages/@aws-cdk/aws-lambda-event-sources/lib/kafka.ts @@ -2,7 +2,6 @@ import * as crypto from 'crypto'; import { ISecurityGroup, IVpc, SubnetSelection } from '@aws-cdk/aws-ec2'; import * as iam from '@aws-cdk/aws-iam'; import * as lambda from '@aws-cdk/aws-lambda'; -import * as msk from '@aws-cdk/aws-msk'; import * as secretsmanager from '@aws-cdk/aws-secretsmanager'; import { Stack } from '@aws-cdk/core'; import { StreamEventSource, StreamEventSourceProps } from './stream'; @@ -32,7 +31,7 @@ export interface ManagedKafkaEventSourceProps extends KafkaEventSourceProps { /** * an MSK cluster construct */ - readonly cluster: msk.ICluster + readonly clusterArn: string; } /** @@ -103,9 +102,9 @@ export class ManagedKafkaEventSource extends StreamEventSource { public bind(target: lambda.IFunction) { target.addEventSourceMapping( - `KafkaEventSource:${this.innerProps.cluster.clusterArn}${this.innerProps.topic}`, + `KafkaEventSource:${this.innerProps.clusterArn}${this.innerProps.topic}`, this.enrichMappingOptions({ - eventSourceArn: this.innerProps.cluster.clusterArn, + eventSourceArn: this.innerProps.clusterArn, startingPosition: this.innerProps.startingPosition, // From https://docs.aws.amazon.com/msk/latest/developerguide/msk-password.html#msk-password-limitations, "Amazon MSK only supports SCRAM-SHA-512 authentication." sourceAccessConfigurations: [{ type: lambda.SourceAccessConfigurationType.SASL_SCRAM_512_AUTH, uri: this.innerProps.secret.secretArn }], @@ -118,7 +117,7 @@ export class ManagedKafkaEventSource extends StreamEventSource { target.addToRolePolicy(new iam.PolicyStatement( { actions: ['kafka:DescribeCluster', 'kafka:GetBootstrapBrokers', 'kafka:ListScramSecrets'], - resources: [this.innerProps.cluster.clusterArn], + resources: [this.innerProps.clusterArn], }, )); diff --git a/packages/@aws-cdk/aws-lambda-event-sources/package.json b/packages/@aws-cdk/aws-lambda-event-sources/package.json index 759608c348992..c58998830ee70 100644 --- a/packages/@aws-cdk/aws-lambda-event-sources/package.json +++ b/packages/@aws-cdk/aws-lambda-event-sources/package.json @@ -77,7 +77,6 @@ "@aws-cdk/aws-iam": "0.0.0", "@aws-cdk/aws-kinesis": "0.0.0", "@aws-cdk/aws-lambda": "0.0.0", - "@aws-cdk/aws-msk": "0.0.0", "@aws-cdk/aws-s3": "0.0.0", "@aws-cdk/aws-s3-notifications": "0.0.0", "@aws-cdk/aws-secretsmanager": "0.0.0", @@ -96,7 +95,6 @@ "@aws-cdk/aws-iam": "0.0.0", "@aws-cdk/aws-kinesis": "0.0.0", "@aws-cdk/aws-lambda": "0.0.0", - "@aws-cdk/aws-msk": "0.0.0", "@aws-cdk/aws-s3": "0.0.0", "@aws-cdk/aws-s3-notifications": "0.0.0", "@aws-cdk/aws-secretsmanager": "0.0.0", diff --git a/packages/@aws-cdk/aws-lambda-event-sources/test/test.kafka.ts b/packages/@aws-cdk/aws-lambda-event-sources/test/test.kafka.ts index 452794014b6e4..be63ce81245e6 100644 --- a/packages/@aws-cdk/aws-lambda-event-sources/test/test.kafka.ts +++ b/packages/@aws-cdk/aws-lambda-event-sources/test/test.kafka.ts @@ -1,7 +1,6 @@ import { arrayWith, expect, haveResource } from '@aws-cdk/assert-internal'; import { SecurityGroup, SubnetType, Vpc } from '@aws-cdk/aws-ec2'; import * as lambda from '@aws-cdk/aws-lambda'; -import * as msk from '@aws-cdk/aws-msk'; import { Secret } from '@aws-cdk/aws-secretsmanager'; import * as cdk from '@aws-cdk/core'; import { Test } from 'nodeunit'; @@ -14,14 +13,14 @@ export = { // GIVEN const stack = new cdk.Stack(); const fn = new TestFunction(stack, 'Fn'); - const cluster = msk.Cluster.fromClusterArn(stack, 'Cluster', 'some-arn'); + const clusterArn = 'some-arn'; const kafkaTopic = 'some-topic'; const secret = new Secret(stack, 'Secret', { secretName: 'AmazonMSK_KafkaSecret' }); // WHEN fn.addEventSource(new sources.ManagedKafkaEventSource( { - cluster: cluster, + clusterArn, topic: kafkaTopic, secret: secret, startingPosition: lambda.StartingPosition.TRIM_HORIZON, @@ -48,7 +47,7 @@ export = { 'kafka:ListScramSecrets', ], Effect: 'Allow', - Resource: cluster.clusterArn, + Resource: clusterArn, }, ], Version: '2012-10-17', @@ -62,7 +61,7 @@ export = { })); expect(stack).to(haveResource('AWS::Lambda::EventSourceMapping', { - EventSourceArn: cluster.clusterArn, + EventSourceArn: clusterArn, FunctionName: { Ref: 'Fn9270CBC0', }, diff --git a/packages/@aws-cdk/aws-route53-targets/README.md b/packages/@aws-cdk/aws-route53-targets/README.md index ba9f1ea7e4831..6ab9c8822cae9 100644 --- a/packages/@aws-cdk/aws-route53-targets/README.md +++ b/packages/@aws-cdk/aws-route53-targets/README.md @@ -24,9 +24,10 @@ This library contains Route53 Alias Record targets for: * API Gateway V2 custom domains ```ts + new route53.ARecord(this, 'AliasRecord', { zone, - target: route53.RecordTarget.fromAlias(new alias.ApiGatewayv2Domain(domainName)), + target: route53.RecordTarget.fromAlias(new alias.ApiGatewayv2DomainProperties(domainName.regionalDomainName, domainName.regionalHostedZoneId)), }); ``` diff --git a/packages/@aws-cdk/aws-route53-targets/lib/api-gatewayv2-domain-name.ts b/packages/@aws-cdk/aws-route53-targets/lib/api-gatewayv2-domain-name.ts index 84472a3772b0e..f0d07882a6ebb 100644 --- a/packages/@aws-cdk/aws-route53-targets/lib/api-gatewayv2-domain-name.ts +++ b/packages/@aws-cdk/aws-route53-targets/lib/api-gatewayv2-domain-name.ts @@ -3,29 +3,17 @@ import * as route53 from '@aws-cdk/aws-route53'; /** * Defines an API Gateway V2 domain name as the alias target. */ -export class ApiGatewayv2Domain implements route53.IAliasRecordTarget { - constructor(private readonly domainName: ApiGatewayDomainName) { } +export class ApiGatewayv2DomainProperties implements route53.IAliasRecordTarget { + /** + * @param regionalDomainName the region-specific Amazon Route 53 Hosted Zone ID of the regional endpoint. + * @param regionalHostedZoneId the domain name associated with the regional endpoint for this custom domain name. + */ + constructor(private readonly regionalDomainName: string, private readonly regionalHostedZoneId: string ) { } public bind(_record: route53.IRecordSet): route53.AliasRecordTargetConfig { return { - dnsName: this.domainName.regionalDomainName, - hostedZoneId: this.domainName.regionalHostedZoneId, + dnsName: this.regionalDomainName, + hostedZoneId: this.regionalHostedZoneId, }; } -} - -/** - * Represents an APIGatewayV2 DomainName - */ -export interface ApiGatewayDomainName { - /** - * The region-specific Amazon Route 53 Hosted Zone ID of the regional endpoint. - */ - readonly regionalHostedZoneId: string; - - /** - * The domain name associated with the regional endpoint for this custom domain name. - */ - readonly regionalDomainName: string; - } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-route53-targets/test/apigatewayv2-target.test.ts b/packages/@aws-cdk/aws-route53-targets/test/apigatewayv2-target.test.ts index 0e1f7304a6860..d2a66e41bde26 100644 --- a/packages/@aws-cdk/aws-route53-targets/test/apigatewayv2-target.test.ts +++ b/packages/@aws-cdk/aws-route53-targets/test/apigatewayv2-target.test.ts @@ -8,10 +8,10 @@ import * as targets from '../lib'; test('targets.ApiGatewayv2Domain can be used to directly reference a domain', () => { // GIVEN const stack = new Stack(); - const domainName = 'example.com'; - const cert = new acm.Certificate(stack, 'cert', { domainName }); - const dn = new apigwv2.DomainName(stack, 'DN', { - domainName, + const name = 'example.com'; + const cert = new acm.Certificate(stack, 'cert', { domainName: name }); + const domainName = new apigwv2.DomainName(stack, 'DN', { + domainName: name, certificate: cert, }); const zone = new route53.HostedZone(stack, 'zone', { @@ -21,7 +21,7 @@ test('targets.ApiGatewayv2Domain can be used to directly reference a domain', () // WHEN new route53.ARecord(stack, 'A', { zone, - target: route53.RecordTarget.fromAlias(new targets.ApiGatewayv2Domain(dn)), + target: route53.RecordTarget.fromAlias(new targets.ApiGatewayv2DomainProperties(domainName.regionalDomainName, domainName.regionalHostedZoneId)), }); // THEN diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/README.md b/packages/@aws-cdk/aws-stepfunctions-tasks/README.md index 8d024db58e552..0888563679d47 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/README.md +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/README.md @@ -21,59 +21,61 @@ This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aw ## Table Of Contents -- [Task](#task) -- [Paths](#paths) - - [InputPath](#inputpath) - - [OutputPath](#outputpath) - - [ResultPath](#resultpath) -- [Parameters](#task-parameters-from-the-state-json) -- [Evaluate Expression](#evaluate-expression) -- [API Gateway](#api-gateway) - - [Call REST API Endpoint](#call-rest-api-endpoint) - - [Call HTTP API Endpoint](#call-http-api-endpoint) -- [Athena](#athena) - - [StartQueryExecution](#startQueryExecution) - - [GetQueryExecution](#getQueryExecution) - - [GetQueryResults](#getQueryResults) - - [StopQueryExecution](#stopQueryExecution) -- [Batch](#batch) - - [SubmitJob](#submitjob) -- [CodeBuild](#codebuild) - - [StartBuild](#startbuild) -- [DynamoDB](#dynamodb) - - [GetItem](#getitem) - - [PutItem](#putitem) - - [DeleteItem](#deleteitem) - - [UpdateItem](#updateitem) -- [ECS](#ecs) - - [RunTask](#runtask) - - [EC2](#ec2) - - [Fargate](#fargate) -- [EMR](#emr) - - [Create Cluster](#create-cluster) - - [Termination Protection](#termination-protection) - - [Terminate Cluster](#terminate-cluster) - - [Add Step](#add-step) - - [Cancel Step](#cancel-step) - - [Modify Instance Fleet](#modify-instance-fleet) - - [Modify Instance Group](#modify-instance-group) -- [EKS](#eks) - - [Call](#call) -- [Glue](#glue) -- [Glue DataBrew](#glue-databrew) -- [Lambda](#lambda) -- [SageMaker](#sagemaker) - - [Create Training Job](#create-training-job) - - [Create Transform Job](#create-transform-job) - - [Create Endpoint](#create-endpoint) - - [Create Endpoint Config](#create-endpoint-config) - - [Create Model](#create-model) - - [Update Endpoint](#update-endpoint) -- [SNS](#sns) -- [Step Functions](#step-functions) - - [Start Execution](#start-execution) - - [Invoke Activity Worker](#invoke-activity) -- [SQS](#sqs) +- [Tasks for AWS Step Functions](#tasks-for-aws-step-functions) + - [Table Of Contents](#table-of-contents) + - [Task](#task) + - [Paths](#paths) + - [InputPath](#inputpath) + - [OutputPath](#outputpath) + - [ResultPath](#resultpath) + - [Task parameters from the state JSON](#task-parameters-from-the-state-json) + - [Evaluate Expression](#evaluate-expression) + - [API Gateway](#api-gateway) + - [Call REST API Endpoint](#call-rest-api-endpoint) + - [Call HTTP API Endpoint](#call-http-api-endpoint) + - [Athena](#athena) + - [StartQueryExecution](#startqueryexecution) + - [GetQueryExecution](#getqueryexecution) + - [GetQueryResults](#getqueryresults) + - [StopQueryExecution](#stopqueryexecution) + - [Batch](#batch) + - [SubmitJob](#submitjob) + - [CodeBuild](#codebuild) + - [StartBuild](#startbuild) + - [DynamoDB](#dynamodb) + - [GetItem](#getitem) + - [PutItem](#putitem) + - [DeleteItem](#deleteitem) + - [UpdateItem](#updateitem) + - [ECS](#ecs) + - [RunTask](#runtask) + - [EC2](#ec2) + - [Fargate](#fargate) + - [EMR](#emr) + - [Create Cluster](#create-cluster) + - [Termination Protection](#termination-protection) + - [Terminate Cluster](#terminate-cluster) + - [Add Step](#add-step) + - [Cancel Step](#cancel-step) + - [Modify Instance Fleet](#modify-instance-fleet) + - [Modify Instance Group](#modify-instance-group) + - [EKS](#eks) + - [Call](#call) + - [Glue](#glue) + - [Glue DataBrew](#glue-databrew) + - [Lambda](#lambda) + - [SageMaker](#sagemaker) + - [Create Training Job](#create-training-job) + - [Create Transform Job](#create-transform-job) + - [Create Endpoint](#create-endpoint) + - [Create Endpoint Config](#create-endpoint-config) + - [Create Model](#create-model) + - [Update Endpoint](#update-endpoint) + - [SNS](#sns) + - [Step Functions](#step-functions) + - [Start Execution](#start-execution) + - [Invoke Activity](#invoke-activity) + - [SQS](#sqs) ## Task @@ -256,7 +258,8 @@ import * as tasks from `@aws-cdk/aws-stepfunctions-tasks`; const httpApi = new apigatewayv2.HttpApi(stack, 'MyHttpApi'); const invokeTask = new tasks.CallApiGatewayHttpApiEndpoint(stack, 'Call HTTP API', { - api: httpApi, + apiId: httpApi.apiId, + apiStack: cdk.Stack.of(httpApi), method: HttpMethod.GET, }); ``` @@ -327,9 +330,9 @@ The [SubmitJob](https://docs.aws.amazon.com/batch/latest/APIReference/API_Submit ```ts fixture=with-batch-job const task = new tasks.BatchSubmitJob(this, 'Submit Job', { - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinitionArn, jobName: 'MyJob', - jobQueue: batchQueue, + jobQueueArn: batchQueueArn, }); ``` diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts index fed72453405da..510a70626973d 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts @@ -1,7 +1,7 @@ import * as iam from '@aws-cdk/aws-iam'; import * as sfn from '@aws-cdk/aws-stepfunctions'; import * as cdk from '@aws-cdk/core'; -import { Construct, IConstruct } from 'constructs'; +import { Construct } from 'constructs'; import { CallApiGatewayEndpointBase } from './base'; import { CallApiGatewayEndpointBaseProps } from './base-types'; @@ -10,25 +10,20 @@ import { CallApiGatewayEndpointBaseProps } from './base-types'; */ export interface CallApiGatewayHttpApiEndpointProps extends CallApiGatewayEndpointBaseProps { /** - * API to call + * The Id of the API to call */ - readonly api: IApiGatewayV2HttpApi; + readonly apiId: string; /** - * Name of the stage where the API is deployed to in API Gateway - * @default '$default' + * The Stack in which the API is defined */ - readonly stageName?: string; -} + readonly apiStack: cdk.Stack; -/** - * An APIGateWayV2 Http API resource representation - */ -export interface IApiGatewayV2HttpApi extends IConstruct { /** - * The identifier of this API Gateway HTTP API. + * Name of the stage where the API is deployed to in API Gateway + * @default '$default' */ - readonly apiId: string; + readonly stageName?: string; } /** @@ -54,16 +49,16 @@ export class CallApiGatewayHttpApiEndpoint extends CallApiGatewayEndpointBase { } private getApiEndpoint(): string { - const apiStack = cdk.Stack.of(this.props.api); - return `${this.props.api.apiId}.execute-api.${apiStack.region}.${apiStack.urlSuffix}`; + const apiStack = cdk.Stack.of(this.props.apiStack); + return `${this.props.apiId}.execute-api.${apiStack.region}.${apiStack.urlSuffix}`; } private getArnForExecuteApi(): string { - const { api, stageName, method, apiPath } = this.props; + const { apiId, stageName, method, apiPath } = this.props; - return cdk.Stack.of(api).formatArn({ + return this.props.apiStack.formatArn({ service: 'execute-api', - resource: api.apiId, + resource: apiId, sep: '/', resourceName: `${stageName}/${method}${apiPath}`, }); diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/batch/run-batch-job.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/batch/run-batch-job.ts index 80c4eb28140be..9ee1cae598095 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/batch/run-batch-job.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/batch/run-batch-job.ts @@ -1,4 +1,3 @@ -import * as batch from '@aws-cdk/aws-batch'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as iam from '@aws-cdk/aws-iam'; import * as sfn from '@aws-cdk/aws-stepfunctions'; @@ -88,9 +87,9 @@ export interface JobDependency { */ export interface RunBatchJobProps { /** - * The job definition used by this job. + * The arn of the job definition used by this job. */ - readonly jobDefinition: batch.IJobDefinition; + readonly jobDefinitionArn: string; /** * The name of the job. @@ -100,9 +99,9 @@ export interface RunBatchJobProps { readonly jobName: string; /** - * The job queue into which the job is submitted. + * The arn of the job queue into which the job is submitted. */ - readonly jobQueue: batch.IJobQueue; + readonly jobQueueArn: string; /** * The array size can be between 2 and 10,000. @@ -242,9 +241,9 @@ export class RunBatchJob implements sfn.IStepFunctionsTask { ), policyStatements: this.configurePolicyStatements(_task), parameters: { - JobDefinition: this.props.jobDefinition.jobDefinitionArn, + JobDefinition: this.props.jobDefinitionArn, JobName: this.props.jobName, - JobQueue: this.props.jobQueue.jobQueueArn, + JobQueue: this.props.jobQueueArn, Parameters: this.props.payload, ArrayProperties: @@ -287,7 +286,7 @@ export class RunBatchJob implements sfn.IStepFunctionsTask { resource: 'job-definition', resourceName: '*', }), - this.props.jobQueue.jobQueueArn, + this.props.jobQueueArn, ], actions: ['batch:SubmitJob'], }), diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/batch/submit-job.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/batch/submit-job.ts index 8064c5e0fe712..0fe43f42e21ac 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/batch/submit-job.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/batch/submit-job.ts @@ -1,4 +1,3 @@ -import * as batch from '@aws-cdk/aws-batch'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as iam from '@aws-cdk/aws-iam'; import * as sfn from '@aws-cdk/aws-stepfunctions'; @@ -87,9 +86,9 @@ export interface BatchJobDependency { */ export interface BatchSubmitJobProps extends sfn.TaskStateBaseProps { /** - * The job definition used by this job. + * The arn of the job definition used by this job. */ - readonly jobDefinition: batch.IJobDefinition; + readonly jobDefinitionArn: string; /** * The name of the job. @@ -99,9 +98,9 @@ export interface BatchSubmitJobProps extends sfn.TaskStateBaseProps { readonly jobName: string; /** - * The job queue into which the job is submitted. + * The arn of the job queue into which the job is submitted. */ - readonly jobQueue: batch.IJobQueue; + readonly jobQueueArn: string; /** * The array size can be between 2 and 10,000. @@ -220,9 +219,9 @@ export class BatchSubmitJob extends sfn.TaskStateBase { return { Resource: integrationResourceArn('batch', 'submitJob', this.integrationPattern), Parameters: sfn.FieldUtils.renderObject({ - JobDefinition: this.props.jobDefinition.jobDefinitionArn, + JobDefinition: this.props.jobDefinitionArn, JobName: this.props.jobName, - JobQueue: this.props.jobQueue.jobQueueArn, + JobQueue: this.props.jobQueueArn, Parameters: this.props.payload?.value, ArrayProperties: this.props.arraySize !== undefined @@ -265,7 +264,7 @@ export class BatchSubmitJob extends sfn.TaskStateBase { resource: 'job-definition', resourceName: '*', }), - this.props.jobQueue.jobQueueArn, + this.props.jobQueueArn, ], actions: ['batch:SubmitJob'], }), diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/package.json b/packages/@aws-cdk/aws-stepfunctions-tasks/package.json index 8ee8228cabd42..8e4c71ef3e10b 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/package.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/package.json @@ -49,6 +49,12 @@ "compat": "cdk-compat", "rosetta:extract": "yarn --silent jsii-rosetta extract" }, + "awslint": { + "exclude": [ + "props-no-arn-refs:@aws-cdk/aws-stepfunctions-tasks.BatchSubmitJobProps.jobDefinitionArn", + "props-no-arn-refs:@aws-cdk/aws-stepfunctions-tasks.BatchSubmitJobProps.jobQueueArn" + ] + }, "keywords": [ "aws", "cdk", @@ -70,13 +76,13 @@ "cdk-integ-tools": "0.0.0", "@aws-cdk/aws-apigatewayv2": "0.0.0", "@aws-cdk/aws-apigatewayv2-integrations": "0.0.0", + "@aws-cdk/aws-batch": "0.0.0", "jest": "^26.6.3", "pkglint": "0.0.0", "@aws-cdk/assert-internal": "0.0.0" }, "dependencies": { "@aws-cdk/aws-apigateway": "0.0.0", - "@aws-cdk/aws-batch": "0.0.0", "@aws-cdk/aws-cloudwatch": "0.0.0", "@aws-cdk/aws-codebuild": "0.0.0", "@aws-cdk/aws-databrew": "0.0.0", @@ -99,7 +105,6 @@ "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { "@aws-cdk/aws-apigateway": "0.0.0", - "@aws-cdk/aws-batch": "0.0.0", "@aws-cdk/aws-cloudwatch": "0.0.0", "@aws-cdk/aws-codebuild": "0.0.0", "@aws-cdk/aws-databrew": "0.0.0", diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/apigateway/call-http-api.test.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/test/apigateway/call-http-api.test.ts index 0e7a2cf616b9a..f72272d13558e 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/apigateway/call-http-api.test.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/apigateway/call-http-api.test.ts @@ -11,7 +11,8 @@ describe('CallApiGatewayHttpApiEndpoint', () => { // WHEN const task = new CallApiGatewayHttpApiEndpoint(stack, 'Call', { - api: httpApi, + apiId: httpApi.apiId, + apiStack: cdk.Stack.of(httpApi), method: HttpMethod.GET, }); @@ -63,7 +64,8 @@ describe('CallApiGatewayHttpApiEndpoint', () => { // WHEN const task = new CallApiGatewayHttpApiEndpoint(stack, 'Call', { - api: httpApi, + apiId: httpApi.apiId, + apiStack: cdk.Stack.of(httpApi), method: HttpMethod.GET, integrationPattern: sfn.IntegrationPattern.WAIT_FOR_TASK_TOKEN, headers: sfn.TaskInput.fromObject({ TaskToken: sfn.JsonPath.taskToken }), @@ -121,7 +123,8 @@ describe('CallApiGatewayHttpApiEndpoint', () => { // THEN expect(() => { new CallApiGatewayHttpApiEndpoint(stack, 'Call', { - api: httpApi, + apiId: httpApi.apiId, + apiStack: cdk.Stack.of(httpApi), method: HttpMethod.GET, integrationPattern: sfn.IntegrationPattern.WAIT_FOR_TASK_TOKEN, }); @@ -136,7 +139,8 @@ describe('CallApiGatewayHttpApiEndpoint', () => { // THEN expect(() => { new CallApiGatewayHttpApiEndpoint(stack, 'Call', { - api: httpApi, + apiId: httpApi.apiId, + apiStack: cdk.Stack.of(httpApi), method: HttpMethod.GET, integrationPattern: sfn.IntegrationPattern.RUN_JOB, }); diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/apigateway/integ.call-http-api.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/test/apigateway/integ.call-http-api.ts index 4eb1f3b896e92..214f2e5a25ba9 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/apigateway/integ.call-http-api.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/apigateway/integ.call-http-api.ts @@ -30,7 +30,8 @@ httpApi.addRoutes({ }); const callEndpointJob = new CallApiGatewayHttpApiEndpoint(stack, 'Call APIGW', { - api: httpApi, + apiId: httpApi.apiId, + apiStack: cdk.Stack.of(httpApi), method: HttpMethod.GET, authType: AuthType.IAM_ROLE, outputPath: sfn.JsonPath.stringAt('$.ResponseBody'), diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/integ.run-batch-job.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/integ.run-batch-job.ts index ff679d770040b..c31aa18cc5fbf 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/integ.run-batch-job.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/integ.run-batch-job.ts @@ -42,9 +42,9 @@ class RunBatchStack extends cdk.Stack { const submitJob = new sfn.Task(this, 'Submit Job', { task: new tasks.RunBatchJob({ - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'MyJob', - jobQueue: batchQueue, + jobQueueArn: batchQueue.jobQueueArn, containerOverrides: { environment: { key: 'value' }, memory: 256, diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/integ.submit-job.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/integ.submit-job.ts index 2e8f603b9d809..93c20cc790c36 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/integ.submit-job.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/integ.submit-job.ts @@ -41,9 +41,9 @@ class RunBatchStack extends cdk.Stack { }); const submitJob = new BatchSubmitJob(this, 'Submit Job', { - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, + jobQueueArn: batchQueue.jobQueueArn, jobName: 'MyJob', - jobQueue: batchQueue, containerOverrides: { environment: { key: 'value' }, memory: cdk.Size.mebibytes(256), diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.test.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.test.ts index ce05c1021e22d..1d290e8bba8eb 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.test.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.test.ts @@ -38,9 +38,9 @@ test('Task with only the required parameters', () => { // WHEN const task = new sfn.Task(stack, 'Task', { task: new tasks.RunBatchJob({ - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, }), }); @@ -72,9 +72,9 @@ test('Task with all the parameters', () => { // WHEN const task = new sfn.Task(stack, 'Task', { task: new tasks.RunBatchJob({ - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, arraySize: 15, containerOverrides: { command: ['sudo', 'rm'], @@ -135,9 +135,9 @@ test('supports tokens', () => { // WHEN const task = new sfn.Task(stack, 'Task', { task: new tasks.RunBatchJob({ - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, + jobQueueArn: batchJobQueue.jobQueueArn, jobName: sfn.JsonPath.stringAt('$.jobName'), - jobQueue: batchJobQueue, arraySize: sfn.JsonPath.numberAt('$.arraySize'), timeout: cdk.Duration.seconds(sfn.JsonPath.numberAt('$.timeout')), attempts: sfn.JsonPath.numberAt('$.attempts'), @@ -181,9 +181,9 @@ test('Task throws if WAIT_FOR_TASK_TOKEN is supplied as service integration patt expect(() => { new sfn.Task(stack, 'Task', { task: new tasks.RunBatchJob({ - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, integrationPattern: sfn.ServiceIntegrationPattern.WAIT_FOR_TASK_TOKEN, }), }); @@ -196,9 +196,9 @@ test('Task throws if environment in containerOverrides contain env with name sta expect(() => { new sfn.Task(stack, 'Task', { task: new tasks.RunBatchJob({ - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, containerOverrides: { environment: { AWS_BATCH_MY_NAME: 'MY_VALUE' }, }, @@ -213,9 +213,9 @@ test('Task throws if arraySize is out of limits 2-10000', () => { expect(() => { new sfn.Task(stack, 'Task', { task: new tasks.RunBatchJob({ - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, arraySize: 1, }), }); @@ -226,9 +226,9 @@ test('Task throws if arraySize is out of limits 2-10000', () => { expect(() => { new sfn.Task(stack, 'Task', { task: new tasks.RunBatchJob({ - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, arraySize: 10001, }), }); @@ -241,9 +241,9 @@ test('Task throws if dependencies exceeds 20', () => { expect(() => { new sfn.Task(stack, 'Task', { task: new tasks.RunBatchJob({ - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, dependsOn: [...Array(21).keys()].map(i => ({ jobId: `${i}`, type: `some_type-${i}`, @@ -259,9 +259,9 @@ test('Task throws if attempts is out of limits 1-10', () => { expect(() => { new sfn.Task(stack, 'Task', { task: new tasks.RunBatchJob({ - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, attempts: 0, }), }); @@ -272,9 +272,9 @@ test('Task throws if attempts is out of limits 1-10', () => { expect(() => { new sfn.Task(stack, 'Task', { task: new tasks.RunBatchJob({ - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, attempts: 11, }), }); @@ -287,9 +287,9 @@ test('Task throws if timeout is less than 60 sec', () => { expect(() => { new sfn.Task(stack, 'Task', { task: new tasks.RunBatchJob({ - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, timeout: cdk.Duration.seconds(59), }), }); diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.test.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.test.ts index d9d0f1f797ee7..ade6e2983106f 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.test.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.test.ts @@ -37,9 +37,9 @@ beforeEach(() => { test('Task with only the required parameters', () => { // WHEN const task = new BatchSubmitJob(stack, 'Task', { - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, }); // THEN @@ -69,9 +69,9 @@ test('Task with only the required parameters', () => { test('Task with all the parameters', () => { // WHEN const task = new BatchSubmitJob(stack, 'Task', { - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, arraySize: 15, containerOverrides: { command: ['sudo', 'rm'], @@ -130,9 +130,9 @@ test('Task with all the parameters', () => { test('supports tokens', () => { // WHEN const task = new BatchSubmitJob(stack, 'Task', { - jobDefinition: batchJobDefinition, jobName: sfn.JsonPath.stringAt('$.jobName'), - jobQueue: batchJobQueue, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, + jobQueueArn: batchJobQueue.jobQueueArn, arraySize: sfn.JsonPath.numberAt('$.arraySize'), timeout: cdk.Duration.seconds(sfn.JsonPath.numberAt('$.timeout')), attempts: sfn.JsonPath.numberAt('$.attempts'), @@ -174,9 +174,9 @@ test('supports tokens', () => { test('supports passing task input into payload', () => { // WHEN const task = new BatchSubmitJob(stack, 'Task', { - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, + jobQueueArn: batchJobQueue.jobQueueArn, jobName: sfn.JsonPath.stringAt('$.jobName'), - jobQueue: batchJobQueue, payload: sfn.TaskInput.fromDataAt('$.foo'), }); @@ -208,9 +208,9 @@ test('supports passing task input into payload', () => { test('Task throws if WAIT_FOR_TASK_TOKEN is supplied as service integration pattern', () => { expect(() => { new BatchSubmitJob(stack, 'Task', { - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, integrationPattern: sfn.IntegrationPattern.WAIT_FOR_TASK_TOKEN, }); }).toThrow( @@ -221,9 +221,9 @@ test('Task throws if WAIT_FOR_TASK_TOKEN is supplied as service integration patt test('Task throws if environment in containerOverrides contain env with name starting with AWS_BATCH', () => { expect(() => { new BatchSubmitJob(stack, 'Task', { - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, containerOverrides: { environment: { AWS_BATCH_MY_NAME: 'MY_VALUE' }, }, @@ -236,9 +236,9 @@ test('Task throws if environment in containerOverrides contain env with name sta test('Task throws if arraySize is out of limits 2-10000', () => { expect(() => { new BatchSubmitJob(stack, 'Task', { - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, arraySize: 1, }); }).toThrow( @@ -247,9 +247,9 @@ test('Task throws if arraySize is out of limits 2-10000', () => { expect(() => { new BatchSubmitJob(stack, 'Task2', { - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, arraySize: 10001, }); }).toThrow( @@ -260,9 +260,9 @@ test('Task throws if arraySize is out of limits 2-10000', () => { test('Task throws if dependencies exceeds 20', () => { expect(() => { new BatchSubmitJob(stack, 'Task', { - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, dependsOn: [...Array(21).keys()].map(i => ({ jobId: `${i}`, type: `some_type-${i}`, @@ -276,9 +276,9 @@ test('Task throws if dependencies exceeds 20', () => { test('Task throws if attempts is out of limits 1-10', () => { expect(() => { new BatchSubmitJob(stack, 'Task', { - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, attempts: 0, }); }).toThrow( @@ -287,9 +287,9 @@ test('Task throws if attempts is out of limits 1-10', () => { expect(() => { new BatchSubmitJob(stack, 'Task2', { - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, attempts: 11, }); }).toThrow( @@ -300,9 +300,9 @@ test('Task throws if attempts is out of limits 1-10', () => { test('Task throws if attempt duration is less than 60 sec', () => { expect(() => { new BatchSubmitJob(stack, 'Task', { - jobDefinition: batchJobDefinition, + jobDefinitionArn: batchJobDefinition.jobDefinitionArn, jobName: 'JobName', - jobQueue: batchJobQueue, + jobQueueArn: batchJobQueue.jobQueueArn, timeout: cdk.Duration.seconds(59), }); }).toThrow( From a1de2eb1934a806a95d8e914bde67cf083942500 Mon Sep 17 00:00:00 2001 From: NetaNir Date: Sun, 18 Apr 2021 02:53:04 -0700 Subject: [PATCH 05/11] cr feedback --- packages/@aws-cdk/aws-events-targets/lib/batch.ts | 7 ++++--- packages/@aws-cdk/aws-events-targets/package.json | 3 +-- .../@aws-cdk/aws-events-targets/test/batch/batch.test.ts | 2 +- .../test/batch/integ.job-definition-events.ts | 4 ++-- .../aws-route53-targets/lib/api-gatewayv2-domain-name.ts | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/@aws-cdk/aws-events-targets/lib/batch.ts b/packages/@aws-cdk/aws-events-targets/lib/batch.ts index 95d69a1c35468..92d6dc81c7290 100644 --- a/packages/@aws-cdk/aws-events-targets/lib/batch.ts +++ b/packages/@aws-cdk/aws-events-targets/lib/batch.ts @@ -49,7 +49,8 @@ export class BatchJob implements events.IRuleTarget { constructor( private readonly jobQueueArn: string, private readonly jobDefinitionArn: string, - private readonly jobStack: Stack, + private readonly jobDefinitionStack: Stack, + private readonly jobQueueStack: Stack, private readonly props: BatchJobProps = {}, ) { } @@ -69,7 +70,7 @@ export class BatchJob implements events.IRuleTarget { arn: this.jobQueueArn, // When scoping resource-level access for job submission, you must provide both job queue and job definition resource types. // https://docs.aws.amazon.com/batch/latest/userguide/ExamplePolicies_BATCH.html#iam-example-restrict-job-def - role: singletonEventRole(this.jobStack, [ + role: singletonEventRole(this.jobDefinitionStack, [ new iam.PolicyStatement({ actions: ['batch:SubmitJob'], resources: [ @@ -79,7 +80,7 @@ export class BatchJob implements events.IRuleTarget { }), ]), input: this.props.event, - targetResource: this.jobStack, + targetResource: this.jobQueueStack, batchParameters, }; } diff --git a/packages/@aws-cdk/aws-events-targets/package.json b/packages/@aws-cdk/aws-events-targets/package.json index daa566296ac8d..0dd8a9b3bb892 100644 --- a/packages/@aws-cdk/aws-events-targets/package.json +++ b/packages/@aws-cdk/aws-events-targets/package.json @@ -73,6 +73,7 @@ "devDependencies": { "@aws-cdk/aws-codecommit": "0.0.0", "@aws-cdk/aws-s3": "0.0.0", + "@aws-cdk/aws-batch": "0.0.0", "aws-sdk": "^2.848.0", "aws-sdk-mock": "^5.1.0", "cdk-build-tools": "0.0.0", @@ -82,7 +83,6 @@ "@aws-cdk/assert-internal": "0.0.0" }, "dependencies": { - "@aws-cdk/aws-batch": "0.0.0", "@aws-cdk/aws-codebuild": "0.0.0", "@aws-cdk/aws-codepipeline": "0.0.0", "@aws-cdk/aws-ec2": "0.0.0", @@ -103,7 +103,6 @@ }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-batch": "0.0.0", "@aws-cdk/aws-codebuild": "0.0.0", "@aws-cdk/aws-codepipeline": "0.0.0", "@aws-cdk/aws-ec2": "0.0.0", diff --git a/packages/@aws-cdk/aws-events-targets/test/batch/batch.test.ts b/packages/@aws-cdk/aws-events-targets/test/batch/batch.test.ts index ae8d62d0949b4..7eb65494a06be 100644 --- a/packages/@aws-cdk/aws-events-targets/test/batch/batch.test.ts +++ b/packages/@aws-cdk/aws-events-targets/test/batch/batch.test.ts @@ -28,7 +28,7 @@ test('use aws batch job as an eventrule target', () => { }); // WHEN - rule.addTarget(new targets.BatchJob(jobQueue.jobQueueArn, jobDefinition.jobDefinitionArn, Stack.of(jobDefinition))); + rule.addTarget(new targets.BatchJob(jobQueue.jobQueueArn, jobDefinition.jobDefinitionArn, Stack.of(jobDefinition), Stack.of(jobQueue))); // THEN expect(stack).to(haveResource('AWS::Events::Rule', { diff --git a/packages/@aws-cdk/aws-events-targets/test/batch/integ.job-definition-events.ts b/packages/@aws-cdk/aws-events-targets/test/batch/integ.job-definition-events.ts index 449c2b3756e14..34f7cdec7766d 100644 --- a/packages/@aws-cdk/aws-events-targets/test/batch/integ.job-definition-events.ts +++ b/packages/@aws-cdk/aws-events-targets/test/batch/integ.job-definition-events.ts @@ -27,11 +27,11 @@ const job = new batch.JobDefinition(stack, 'MyJob', { const timer = new events.Rule(stack, 'Timer', { schedule: events.Schedule.rate(cdk.Duration.minutes(1)), }); -timer.addTarget(new targets.BatchJob(queue.jobQueueArn, job.jobDefinitionArn, cdk.Stack.of(job))); +timer.addTarget(new targets.BatchJob(queue.jobQueueArn, job.jobDefinitionArn, cdk.Stack.of(job), cdk.Stack.of(queue))); const timer2 = new events.Rule(stack, 'Timer2', { schedule: events.Schedule.rate(cdk.Duration.minutes(2)), }); -timer2.addTarget(new targets.BatchJob(queue.jobQueueArn, job.jobDefinitionArn, cdk.Stack.of(job))); +timer2.addTarget(new targets.BatchJob(queue.jobQueueArn, job.jobDefinitionArn, cdk.Stack.of(job), cdk.Stack.of(queue))); app.synth(); diff --git a/packages/@aws-cdk/aws-route53-targets/lib/api-gatewayv2-domain-name.ts b/packages/@aws-cdk/aws-route53-targets/lib/api-gatewayv2-domain-name.ts index f0d07882a6ebb..dab8032cd3d1b 100644 --- a/packages/@aws-cdk/aws-route53-targets/lib/api-gatewayv2-domain-name.ts +++ b/packages/@aws-cdk/aws-route53-targets/lib/api-gatewayv2-domain-name.ts @@ -8,7 +8,7 @@ export class ApiGatewayv2DomainProperties implements route53.IAliasRecordTarget * @param regionalDomainName the region-specific Amazon Route 53 Hosted Zone ID of the regional endpoint. * @param regionalHostedZoneId the domain name associated with the regional endpoint for this custom domain name. */ - constructor(private readonly regionalDomainName: string, private readonly regionalHostedZoneId: string ) { } + constructor(private readonly regionalDomainName: string, private readonly regionalHostedZoneId: string) { } public bind(_record: route53.IRecordSet): route53.AliasRecordTargetConfig { return { From 0ad52d4acc2a446be30694802dce3a5b83d826c9 Mon Sep 17 00:00:00 2001 From: NetaNir Date: Sun, 18 Apr 2021 03:04:23 -0700 Subject: [PATCH 06/11] cr --- .../aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts index 510a70626973d..4624bcba049a0 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/call-http-api.ts @@ -49,7 +49,7 @@ export class CallApiGatewayHttpApiEndpoint extends CallApiGatewayEndpointBase { } private getApiEndpoint(): string { - const apiStack = cdk.Stack.of(this.props.apiStack); + const apiStack = this.props.apiStack; return `${this.props.apiId}.execute-api.${apiStack.region}.${apiStack.urlSuffix}`; } From 3a0ca903d0ef22d01e63c4d26f1102392e6e23bf Mon Sep 17 00:00:00 2001 From: NetaNir Date: Sun, 18 Apr 2021 17:28:23 -0700 Subject: [PATCH 07/11] fix tests --- packages/@aws-cdk/aws-events-targets/lib/batch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-events-targets/lib/batch.ts b/packages/@aws-cdk/aws-events-targets/lib/batch.ts index 92d6dc81c7290..5aaf8cd733c25 100644 --- a/packages/@aws-cdk/aws-events-targets/lib/batch.ts +++ b/packages/@aws-cdk/aws-events-targets/lib/batch.ts @@ -49,8 +49,8 @@ export class BatchJob implements events.IRuleTarget { constructor( private readonly jobQueueArn: string, private readonly jobDefinitionArn: string, - private readonly jobDefinitionStack: Stack, private readonly jobQueueStack: Stack, + private readonly jobDefinitionStack: Stack, private readonly props: BatchJobProps = {}, ) { } From 06f588c81db1ac6dd7111a5d9196f7cab8dfc388 Mon Sep 17 00:00:00 2001 From: NetaNir Date: Sun, 18 Apr 2021 18:00:18 -0700 Subject: [PATCH 08/11] fix tests --- .../@aws-cdk/aws-events-targets/lib/batch.ts | 29 +++++++++++++++---- .../test/batch/batch.test.ts | 2 +- .../test/batch/integ.job-definition-events.ts | 4 +-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/packages/@aws-cdk/aws-events-targets/lib/batch.ts b/packages/@aws-cdk/aws-events-targets/lib/batch.ts index 5aaf8cd733c25..17920c5cc8fd2 100644 --- a/packages/@aws-cdk/aws-events-targets/lib/batch.ts +++ b/packages/@aws-cdk/aws-events-targets/lib/batch.ts @@ -1,6 +1,6 @@ import * as events from '@aws-cdk/aws-events'; import * as iam from '@aws-cdk/aws-iam'; -import { Names, Stack } from '@aws-cdk/core'; +import { Names, IConstruct } from '@aws-cdk/core'; import { singletonEventRole } from './util'; /** @@ -43,14 +43,33 @@ export interface BatchJobProps { /** * Use an AWS Batch Job / Queue as an event rule target. + * Most likely the code will look something like this: + * `new BatchJob(jobQueue.jobQueueArn, jobQueue, jobDefinition.jobDefinitionArn, jobDefinition)` + * + * In the future this API will be improved to be fully typed * @experimental */ export class BatchJob implements events.IRuleTarget { constructor( + /** + * The JobQueue arn + */ private readonly jobQueueArn: string, + + /** + * The JobQueue Construct + */ + private readonly jobQueueScope: IConstruct, + + /** + * The jobDefinition arn + */ private readonly jobDefinitionArn: string, - private readonly jobQueueStack: Stack, - private readonly jobDefinitionStack: Stack, + + /** + * The JobQueue Construct + */ + private readonly jobDefinitionScope: IConstruct, private readonly props: BatchJobProps = {}, ) { } @@ -70,7 +89,7 @@ export class BatchJob implements events.IRuleTarget { arn: this.jobQueueArn, // When scoping resource-level access for job submission, you must provide both job queue and job definition resource types. // https://docs.aws.amazon.com/batch/latest/userguide/ExamplePolicies_BATCH.html#iam-example-restrict-job-def - role: singletonEventRole(this.jobDefinitionStack, [ + role: singletonEventRole(this.jobDefinitionScope, [ new iam.PolicyStatement({ actions: ['batch:SubmitJob'], resources: [ @@ -80,7 +99,7 @@ export class BatchJob implements events.IRuleTarget { }), ]), input: this.props.event, - targetResource: this.jobQueueStack, + targetResource: this.jobQueueScope, batchParameters, }; } diff --git a/packages/@aws-cdk/aws-events-targets/test/batch/batch.test.ts b/packages/@aws-cdk/aws-events-targets/test/batch/batch.test.ts index 7eb65494a06be..acdf2477832f5 100644 --- a/packages/@aws-cdk/aws-events-targets/test/batch/batch.test.ts +++ b/packages/@aws-cdk/aws-events-targets/test/batch/batch.test.ts @@ -28,7 +28,7 @@ test('use aws batch job as an eventrule target', () => { }); // WHEN - rule.addTarget(new targets.BatchJob(jobQueue.jobQueueArn, jobDefinition.jobDefinitionArn, Stack.of(jobDefinition), Stack.of(jobQueue))); + rule.addTarget(new targets.BatchJob(jobQueue.jobQueueArn, jobQueue, jobDefinition.jobDefinitionArn, jobDefinition)); // THEN expect(stack).to(haveResource('AWS::Events::Rule', { diff --git a/packages/@aws-cdk/aws-events-targets/test/batch/integ.job-definition-events.ts b/packages/@aws-cdk/aws-events-targets/test/batch/integ.job-definition-events.ts index 34f7cdec7766d..01d1058eb4064 100644 --- a/packages/@aws-cdk/aws-events-targets/test/batch/integ.job-definition-events.ts +++ b/packages/@aws-cdk/aws-events-targets/test/batch/integ.job-definition-events.ts @@ -27,11 +27,11 @@ const job = new batch.JobDefinition(stack, 'MyJob', { const timer = new events.Rule(stack, 'Timer', { schedule: events.Schedule.rate(cdk.Duration.minutes(1)), }); -timer.addTarget(new targets.BatchJob(queue.jobQueueArn, job.jobDefinitionArn, cdk.Stack.of(job), cdk.Stack.of(queue))); +timer.addTarget(new targets.BatchJob(queue.jobQueueArn, queue, job.jobDefinitionArn, job)); const timer2 = new events.Rule(stack, 'Timer2', { schedule: events.Schedule.rate(cdk.Duration.minutes(2)), }); -timer2.addTarget(new targets.BatchJob(queue.jobQueueArn, job.jobDefinitionArn, cdk.Stack.of(job), cdk.Stack.of(queue))); +timer2.addTarget(new targets.BatchJob(queue.jobQueueArn, queue, job.jobDefinitionArn, job)); app.synth(); From 559f85bc41f5678e6cc2f9e11bbe9bbfb9e9b445 Mon Sep 17 00:00:00 2001 From: NetaNir Date: Sun, 18 Apr 2021 18:17:28 -0700 Subject: [PATCH 09/11] docs --- packages/@aws-cdk/aws-events-targets/lib/batch.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-events-targets/lib/batch.ts b/packages/@aws-cdk/aws-events-targets/lib/batch.ts index 17920c5cc8fd2..8cf48f45f6959 100644 --- a/packages/@aws-cdk/aws-events-targets/lib/batch.ts +++ b/packages/@aws-cdk/aws-events-targets/lib/batch.ts @@ -57,7 +57,7 @@ export class BatchJob implements events.IRuleTarget { private readonly jobQueueArn: string, /** - * The JobQueue Construct + * The JobQueue Resource */ private readonly jobQueueScope: IConstruct, @@ -67,7 +67,7 @@ export class BatchJob implements events.IRuleTarget { private readonly jobDefinitionArn: string, /** - * The JobQueue Construct + * The JobQueue Resource */ private readonly jobDefinitionScope: IConstruct, private readonly props: BatchJobProps = {}, From c5b502e608aced4fcde857ed630ab498bff5ea67 Mon Sep 17 00:00:00 2001 From: NetaNir Date: Sun, 18 Apr 2021 19:04:08 -0700 Subject: [PATCH 10/11] allowed breaking changes --- allowed-breaking-changes.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/allowed-breaking-changes.txt b/allowed-breaking-changes.txt index 6c0a5aa9fd2ef..66b6702f1d342 100644 --- a/allowed-breaking-changes.txt +++ b/allowed-breaking-changes.txt @@ -72,3 +72,5 @@ removed:@aws-cdk/aws-stepfunctions-tasks.RunBatchJobProps.jobQueue removed:@aws-cdk/aws-stepfunctions-tasks.BatchSubmitJobProps.jobQueue removed:@aws-cdk/aws-stepfunctions-tasks.BatchSubmitJobProps.jobDefinition strengthened:@aws-cdk/aws-stepfunctions-tasks.BatchSubmitJobProps +removed:@aws-cdk/aws-lambda-event-sources.ManagedKafkaEventSourceProps.cluster +strengthened:@aws-cdk/aws-lambda-event-sources.ManagedKafkaEventSourceProps From a78b415664d2f2f9826086716121ed4f24bff65d Mon Sep 17 00:00:00 2001 From: NetaNir Date: Sun, 18 Apr 2021 19:35:21 -0700 Subject: [PATCH 11/11] alllowed --- allowed-breaking-changes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/allowed-breaking-changes.txt b/allowed-breaking-changes.txt index 66b6702f1d342..47f19a6719d17 100644 --- a/allowed-breaking-changes.txt +++ b/allowed-breaking-changes.txt @@ -65,7 +65,7 @@ weakened:@aws-cdk/aws-events.RuleTargetConfig # replace interface with untyped properties to order to break stable to experimental dependencies removed:@aws-cdk/aws-stepfunctions-tasks.CallApiGatewayHttpApiEndpointProps.api strengthened:@aws-cdk/aws-stepfunctions-tasks.CallApiGatewayHttpApiEndpointProps -removed:@aws-cdk/aws-route53-targets.ApiGatewayv2Domain. +removed:@aws-cdk/aws-route53-targets.ApiGatewayv2Domain removed:@aws-cdk/aws-stepfunctions-tasks.RunBatchJobProps.jobDefinition removed:@aws-cdk/aws-stepfunctions-tasks.RunBatchJobProps.jobDefinition removed:@aws-cdk/aws-stepfunctions-tasks.RunBatchJobProps.jobQueue