Skip to content

Commit

Permalink
use ICfnQueue everywehre possible
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizencc committed Dec 1, 2023
1 parent 2968f0f commit 27ba42e
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions packages/@aws-cdk/aws-iot-actions-alpha/lib/sqs-queue-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ export interface SqsQueueActionProps extends CommonActionProps {
*
* @default false
*/
readonly useBase64?: boolean
readonly useBase64?: boolean;
}

/**
* The action to write the data from an MQTT message to an Amazon SQS queue.
*/
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;
Expand All @@ -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,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions packages/aws-cdk-lib/aws-events-targets/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ 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.
*
* @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.
Expand Down
1 change: 0 additions & 1 deletion packages/aws-cdk-lib/aws-sns/lib/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export interface SubscriptionProps extends SubscriptionOptions {
* this class.
*/
export class Subscription extends Resource {

/**
* The DLQ associated with this subscription if present.
*/
Expand Down
7 changes: 3 additions & 4 deletions packages/aws-cdk-lib/aws-sqs/lib/policy.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -11,7 +10,7 @@ export interface QueuePolicyProps {
/**
* The set of queues this policy applies to.
*/
readonly queues: IQueue[];
readonly queues: ICfnQueue[];
}

/**
Expand Down Expand Up @@ -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),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 27ba42e

Please sign in to comment.