From 27ba42ebeb248007d766d49f0cd6018fc6c6379e Mon Sep 17 00:00:00 2001 From: Kaizen Conroy Date: Fri, 1 Dec 2023 16:57:11 -0500 Subject: [PATCH] use ICfnQueue everywehre possible --- packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts | 4 ++-- .../aws-iot-actions-alpha/lib/sqs-queue-action.ts | 10 +++++----- .../lib/base/queue-processing-service-base.ts | 6 +++--- packages/aws-cdk-lib/aws-events-targets/lib/util.ts | 5 +++-- .../aws-sns-subscriptions/lib/subscription.ts | 2 ++ packages/aws-cdk-lib/aws-sns/lib/subscription.ts | 1 - packages/aws-cdk-lib/aws-sqs/lib/policy.ts | 7 +++---- .../aws-stepfunctions-tasks/lib/sqs/send-message.ts | 3 +-- .../aws-stepfunctions-tasks/lib/sqs/send-to-queue.ts | 1 - 9 files changed, 19 insertions(+), 20 deletions(-) diff --git a/packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts b/packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts index 3f21307843370..134959a2a451b 100644 --- a/packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts +++ b/packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts @@ -86,8 +86,8 @@ export class SqsDestination implements IEventDestination { public readonly type: SourceType; public readonly policyDocument?: iam.PolicyDocument; - constructor(queue: sqs.IQueue) { - this.extensionUri = queue.queueArn; + constructor(queue: sqs.ICfnQueue) { + this.extensionUri = queue.attrArn; this.type = SourceType.SQS; const policy = new iam.PolicyStatement({ effect: iam.Effect.ALLOW, diff --git a/packages/@aws-cdk/aws-iot-actions-alpha/lib/sqs-queue-action.ts b/packages/@aws-cdk/aws-iot-actions-alpha/lib/sqs-queue-action.ts index 44f222a46c6db..d678ab82e48e2 100644 --- a/packages/@aws-cdk/aws-iot-actions-alpha/lib/sqs-queue-action.ts +++ b/packages/@aws-cdk/aws-iot-actions-alpha/lib/sqs-queue-action.ts @@ -13,7 +13,7 @@ export interface SqsQueueActionProps extends CommonActionProps { * * @default false */ - readonly useBase64?: boolean + readonly useBase64?: boolean; } /** @@ -21,14 +21,14 @@ export interface SqsQueueActionProps extends CommonActionProps { */ export class SqsQueueAction implements iot.IAction { private readonly role?: iam.IRole; - private readonly queue: sqs.IQueue; + private readonly queue: sqs.ICfnQueue; private readonly useBase64?: boolean; /** * @param queue The Amazon SQS queue to which to write data. * @param props Optional properties to not use default */ - constructor(queue: sqs.IQueue, props: SqsQueueActionProps = {}) { + constructor(queue: sqs.ICfnQueue, props: SqsQueueActionProps = {}) { this.queue = queue; this.role = props.role; this.useBase64 = props.useBase64; @@ -41,13 +41,13 @@ export class SqsQueueAction implements iot.IAction { const role = this.role ?? singletonActionRole(rule); role.addToPrincipalPolicy(new iam.PolicyStatement({ actions: ['sqs:SendMessage'], - resources: [this.queue.queueArn], + resources: [this.queue.attrArn], })); return { configuration: { sqs: { - queueUrl: this.queue.queueUrl, + queueUrl: this.queue.attrQueueUrl, useBase64: this.useBase64, roleArn: role.roleArn, }, diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts index 385caafdc0ca2..10bf88af1e27b 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts @@ -90,7 +90,7 @@ export interface QueueProcessingServiceBaseProps { * If specified and this is a FIFO queue, the queue name must end in the string '.fifo'. See * [CreateQueue](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_CreateQueue.html) * - * @default 'SQSQueue with CloudFormation-generated name' + * @default - SQS Queue with CloudFormation-generated name */ readonly queue?: IQueue; @@ -125,14 +125,14 @@ export interface QueueProcessingServiceBaseProps { * * @default - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is (desiredTaskCount * 2); if true, the default is 2. */ - readonly maxScalingCapacity?: number + readonly maxScalingCapacity?: number; /** * Minimum capacity to scale to. * * @default - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is the desiredTaskCount; if true, the default is 1. */ - readonly minScalingCapacity?: number + readonly minScalingCapacity?: number; /** * The intervals for scaling based on the SQS queue's ApproximateNumberOfMessagesVisible metric. diff --git a/packages/aws-cdk-lib/aws-events-targets/lib/util.ts b/packages/aws-cdk-lib/aws-events-targets/lib/util.ts index ab279d03f4b60..af4c834e8c49c 100644 --- a/packages/aws-cdk-lib/aws-events-targets/lib/util.ts +++ b/packages/aws-cdk-lib/aws-events-targets/lib/util.ts @@ -19,7 +19,8 @@ export interface TargetBaseProps { * * @default - no dead-letter queue */ - readonly deadLetterQueue?: sqs.IQueue; + readonly deadLetterQueue?: sqs.ICfnQueue; + /** * The maximum age of a request that Lambda sends to a function for * processing. @@ -50,7 +51,7 @@ export function bindBaseTargetConfig(props: TargetBaseProps) { let { deadLetterQueue, retryAttempts, maxEventAge } = props; return { - deadLetterConfig: deadLetterQueue ? { arn: deadLetterQueue?.queueArn } : undefined, + deadLetterConfig: deadLetterQueue ? { arn: deadLetterQueue?.attrArn } : undefined, retryPolicy: (retryAttempts !== undefined && retryAttempts >= 0) || maxEventAge ? { maximumRetryAttempts: retryAttempts, diff --git a/packages/aws-cdk-lib/aws-sns-subscriptions/lib/subscription.ts b/packages/aws-cdk-lib/aws-sns-subscriptions/lib/subscription.ts index cb00ef6507d53..d9d144959ec8d 100644 --- a/packages/aws-cdk-lib/aws-sns-subscriptions/lib/subscription.ts +++ b/packages/aws-cdk-lib/aws-sns-subscriptions/lib/subscription.ts @@ -11,6 +11,7 @@ export interface SubscriptionProps { * @default - all messages are delivered */ readonly filterPolicy?: { [attribute: string]: sns.SubscriptionFilter }; + /** * The filter policy that is applied on the message body. * To apply a filter policy to the message attributes, use `filterPolicy`. A maximum of one of `filterPolicyWithMessageBody` and `filterPolicy` may be used. @@ -18,6 +19,7 @@ export interface SubscriptionProps { * @default - all messages are delivered */ readonly filterPolicyWithMessageBody?: { [attribute: string]: sns.FilterOrPolicy }; + /** * Queue to be used as dead letter queue. * If not passed no dead letter queue is enabled. diff --git a/packages/aws-cdk-lib/aws-sns/lib/subscription.ts b/packages/aws-cdk-lib/aws-sns/lib/subscription.ts index 7701a5dd75def..a73cd157454c2 100644 --- a/packages/aws-cdk-lib/aws-sns/lib/subscription.ts +++ b/packages/aws-cdk-lib/aws-sns/lib/subscription.ts @@ -85,7 +85,6 @@ export interface SubscriptionProps extends SubscriptionOptions { * this class. */ export class Subscription extends Resource { - /** * The DLQ associated with this subscription if present. */ diff --git a/packages/aws-cdk-lib/aws-sqs/lib/policy.ts b/packages/aws-cdk-lib/aws-sqs/lib/policy.ts index 2a427c0522c19..eacdbee8110b3 100644 --- a/packages/aws-cdk-lib/aws-sqs/lib/policy.ts +++ b/packages/aws-cdk-lib/aws-sqs/lib/policy.ts @@ -1,6 +1,5 @@ import { Construct } from 'constructs'; -import { IQueue } from './queue-base'; -import { CfnQueuePolicy } from './sqs.generated'; +import { CfnQueuePolicy, ICfnQueue } from './sqs.generated'; import { PolicyDocument } from '../../aws-iam'; import { Resource } from '../../core'; @@ -11,7 +10,7 @@ export interface QueuePolicyProps { /** * The set of queues this policy applies to. */ - readonly queues: IQueue[]; + readonly queues: ICfnQueue[]; } /** @@ -39,7 +38,7 @@ export class QueuePolicy extends Resource { new CfnQueuePolicy(this, 'Resource', { policyDocument: this.document, - queues: props.queues.map(q => q.queueUrl), + queues: props.queues.map(q => q.attrQueueUrl), }); } diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/sqs/send-message.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/sqs/send-message.ts index 38903d1789739..7c245f937c337 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/sqs/send-message.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/sqs/send-message.ts @@ -9,11 +9,10 @@ import { integrationResourceArn, validatePatternSupported } from '../private/tas * Properties for sending a message to an SQS queue */ export interface SqsSendMessageProps extends sfn.TaskStateBaseProps { - /** * The SQS queue that messages will be sent to */ - readonly queue: sqs.IQueue + readonly queue: sqs.IQueue; /** * The text message to send to the queue. diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/sqs/send-to-queue.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/sqs/send-to-queue.ts index f1ebe96dd76e6..d77f89b9c4584 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/sqs/send-to-queue.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/sqs/send-to-queue.ts @@ -60,7 +60,6 @@ export interface SendToQueueProps { * @deprecated Use `SqsSendMessage` */ export class SendToQueue implements sfn.IStepFunctionsTask { - private readonly integrationPattern: sfn.ServiceIntegrationPattern; constructor(private readonly queue: sqs.IQueue, private readonly props: SendToQueueProps) {