Skip to content

Latest commit

 

History

History
763 lines (459 loc) · 26 KB

API.md

File metadata and controls

763 lines (459 loc) · 26 KB

API Reference

Constructs

TweetQueue

Initializers

import { TweetQueue } from 'cdk-tweet-queue'

new TweetQueue(parent: Construct, id: string, props: TweetQueueProps)
Name Type Description
parent constructs.Construct No description.
id string No description.
props TweetQueueProps No description.

parentRequired
  • Type: constructs.Construct

idRequired
  • Type: string

propsRequired

Methods

Name Description
toString Returns a string representation of this construct.
applyRemovalPolicy Apply the given removal policy to this resource.
addToResourcePolicy Adds a statement to the IAM resource policy associated with this queue.
grant Grant the actions defined in queueActions to the identity Principal given on this SQS queue resource.
grantConsumeMessages Grant permissions to consume messages from a queue.
grantPurge Grant an IAM principal permissions to purge all messages from the queue.
grantSendMessages Grant access to send messages to a queue to the given identity.
metric Return the given named metric for this Queue.
metricApproximateAgeOfOldestMessage The approximate age of the oldest non-deleted message in the queue.
metricApproximateNumberOfMessagesDelayed The number of messages in the queue that are delayed and not available for reading immediately.
metricApproximateNumberOfMessagesNotVisible The number of messages that are in flight.
metricApproximateNumberOfMessagesVisible The number of messages available for retrieval from the queue.
metricNumberOfEmptyReceives The number of ReceiveMessage API calls that did not return a message.
metricNumberOfMessagesDeleted The number of messages deleted from the queue.
metricNumberOfMessagesReceived The number of messages returned by calls to the ReceiveMessage action.
metricNumberOfMessagesSent The number of messages added to a queue.
metricSentMessageSize The size of messages added to a queue.

toString
public toString(): string

Returns a string representation of this construct.

applyRemovalPolicy
public applyRemovalPolicy(policy: RemovalPolicy): void

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

policyRequired
  • Type: aws-cdk-lib.RemovalPolicy

addToResourcePolicy
public addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResult

Adds a statement to the IAM resource policy associated with this queue.

If this queue was created in this stack (new Queue), a queue policy will be automatically created upon the first call to addToPolicy. If the queue is imported (Queue.import), then this is a no-op.

statementRequired
  • Type: aws-cdk-lib.aws_iam.PolicyStatement

grant
public grant(grantee: IGrantable, actions: ...string[]): Grant

Grant the actions defined in queueActions to the identity Principal given on this SQS queue resource.

granteeRequired
  • Type: aws-cdk-lib.aws_iam.IGrantable

Principal to grant right to.


actionsRequired
  • Type: ...string[]

The actions to grant.


grantConsumeMessages
public grantConsumeMessages(grantee: IGrantable): Grant

Grant permissions to consume messages from a queue.

This will grant the following permissions:

  • sqs:ChangeMessageVisibility
  • sqs:DeleteMessage
  • sqs:ReceiveMessage
  • sqs:GetQueueAttributes
  • sqs:GetQueueUrl

If encryption is used, permission to use the key to decrypt the contents of the queue will also be granted to the same principal.

This will grant the following KMS permissions:

  • kms:Decrypt
granteeRequired
  • Type: aws-cdk-lib.aws_iam.IGrantable

Principal to grant consume rights to.


grantPurge
public grantPurge(grantee: IGrantable): Grant

Grant an IAM principal permissions to purge all messages from the queue.

This will grant the following permissions:

  • sqs:PurgeQueue
  • sqs:GetQueueAttributes
  • sqs:GetQueueUrl
granteeRequired
  • Type: aws-cdk-lib.aws_iam.IGrantable

Principal to grant send rights to.


grantSendMessages
public grantSendMessages(grantee: IGrantable): Grant

Grant access to send messages to a queue to the given identity.

This will grant the following permissions:

  • sqs:SendMessage
  • sqs:GetQueueAttributes
  • sqs:GetQueueUrl

If encryption is used, permission to use the key to encrypt/decrypt the contents of the queue will also be granted to the same principal.

This will grant the following KMS permissions:

  • kms:Decrypt
  • kms:Encrypt
  • kms:ReEncrypt*
  • kms:GenerateDataKey*
granteeRequired
  • Type: aws-cdk-lib.aws_iam.IGrantable

Principal to grant send rights to.


metric
public metric(metricName: string, props?: MetricOptions): Metric

Return the given named metric for this Queue.

metricNameRequired
  • Type: string

propsOptional
  • Type: aws-cdk-lib.aws_cloudwatch.MetricOptions

metricApproximateAgeOfOldestMessage
public metricApproximateAgeOfOldestMessage(props?: MetricOptions): Metric

The approximate age of the oldest non-deleted message in the queue.

Maximum over 5 minutes

propsOptional
  • Type: aws-cdk-lib.aws_cloudwatch.MetricOptions

metricApproximateNumberOfMessagesDelayed
public metricApproximateNumberOfMessagesDelayed(props?: MetricOptions): Metric

The number of messages in the queue that are delayed and not available for reading immediately.

Maximum over 5 minutes

propsOptional
  • Type: aws-cdk-lib.aws_cloudwatch.MetricOptions

metricApproximateNumberOfMessagesNotVisible
public metricApproximateNumberOfMessagesNotVisible(props?: MetricOptions): Metric

The number of messages that are in flight.

Maximum over 5 minutes

propsOptional
  • Type: aws-cdk-lib.aws_cloudwatch.MetricOptions

metricApproximateNumberOfMessagesVisible
public metricApproximateNumberOfMessagesVisible(props?: MetricOptions): Metric

The number of messages available for retrieval from the queue.

Maximum over 5 minutes

propsOptional
  • Type: aws-cdk-lib.aws_cloudwatch.MetricOptions

metricNumberOfEmptyReceives
public metricNumberOfEmptyReceives(props?: MetricOptions): Metric

The number of ReceiveMessage API calls that did not return a message.

Sum over 5 minutes

propsOptional
  • Type: aws-cdk-lib.aws_cloudwatch.MetricOptions

metricNumberOfMessagesDeleted
public metricNumberOfMessagesDeleted(props?: MetricOptions): Metric

The number of messages deleted from the queue.

Sum over 5 minutes

propsOptional
  • Type: aws-cdk-lib.aws_cloudwatch.MetricOptions

metricNumberOfMessagesReceived
public metricNumberOfMessagesReceived(props?: MetricOptions): Metric

The number of messages returned by calls to the ReceiveMessage action.

Sum over 5 minutes

propsOptional
  • Type: aws-cdk-lib.aws_cloudwatch.MetricOptions

metricNumberOfMessagesSent
public metricNumberOfMessagesSent(props?: MetricOptions): Metric

The number of messages added to a queue.

Sum over 5 minutes

propsOptional
  • Type: aws-cdk-lib.aws_cloudwatch.MetricOptions

metricSentMessageSize
public metricSentMessageSize(props?: MetricOptions): Metric

The size of messages added to a queue.

Average over 5 minutes

propsOptional
  • Type: aws-cdk-lib.aws_cloudwatch.MetricOptions

Static Functions

Name Description
isConstruct Checks if x is a construct.
isOwnedResource Returns true if the construct was created by CDK, and false otherwise.
isResource Check whether the given construct is a Resource.
fromQueueArn Import an existing SQS queue provided an ARN.
fromQueueAttributes Import an existing queue.

isConstruct
import { TweetQueue } from 'cdk-tweet-queue'

TweetQueue.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isOwnedResource
import { TweetQueue } from 'cdk-tweet-queue'

TweetQueue.isOwnedResource(construct: IConstruct)

Returns true if the construct was created by CDK, and false otherwise.

constructRequired
  • Type: constructs.IConstruct

isResource
import { TweetQueue } from 'cdk-tweet-queue'

TweetQueue.isResource(construct: IConstruct)

Check whether the given construct is a Resource.

constructRequired
  • Type: constructs.IConstruct

fromQueueArn
import { TweetQueue } from 'cdk-tweet-queue'

TweetQueue.fromQueueArn(scope: Construct, id: string, queueArn: string)

Import an existing SQS queue provided an ARN.

scopeRequired
  • Type: constructs.Construct

The parent creating construct.


idRequired
  • Type: string

The construct's name.


queueArnRequired
  • Type: string

queue ARN (i.e. arn:aws:sqs:us-east-2:444455556666:queue1).


fromQueueAttributes
import { TweetQueue } from 'cdk-tweet-queue'

TweetQueue.fromQueueAttributes(scope: Construct, id: string, attrs: QueueAttributes)

Import an existing queue.

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: string

attrsRequired
  • Type: aws-cdk-lib.aws_sqs.QueueAttributes

Properties

Name Type Description
node constructs.Node The tree node.
env aws-cdk-lib.ResourceEnvironment The environment this resource belongs to.
stack aws-cdk-lib.Stack The stack in which this resource is defined.
fifo boolean Whether this queue is an Amazon SQS FIFO queue.
queueArn string The ARN of this queue.
queueName string The name of this queue.
queueUrl string The URL of this queue.
encryptionMasterKey aws-cdk-lib.aws_kms.IKey If this queue is encrypted, this is the KMS key.
encryptionType aws-cdk-lib.aws_sqs.QueueEncryption Whether the contents of the queue are encrypted, and by what type of key.
deadLetterQueue aws-cdk-lib.aws_sqs.DeadLetterQueue If this queue is configured with a dead-letter queue, this is the dead-letter queue settings.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


envRequired
public readonly env: ResourceEnvironment;
  • Type: aws-cdk-lib.ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


stackRequired
public readonly stack: Stack;
  • Type: aws-cdk-lib.Stack

The stack in which this resource is defined.


fifoRequired
public readonly fifo: boolean;
  • Type: boolean

Whether this queue is an Amazon SQS FIFO queue.

If false, this is a standard queue.


queueArnRequired
public readonly queueArn: string;
  • Type: string

The ARN of this queue.


queueNameRequired
public readonly queueName: string;
  • Type: string

The name of this queue.


queueUrlRequired
public readonly queueUrl: string;
  • Type: string

The URL of this queue.


encryptionMasterKeyOptional
public readonly encryptionMasterKey: IKey;
  • Type: aws-cdk-lib.aws_kms.IKey

If this queue is encrypted, this is the KMS key.


encryptionTypeOptional
public readonly encryptionType: QueueEncryption;
  • Type: aws-cdk-lib.aws_sqs.QueueEncryption

Whether the contents of the queue are encrypted, and by what type of key.


deadLetterQueueOptional
public readonly deadLetterQueue: DeadLetterQueue;
  • Type: aws-cdk-lib.aws_sqs.DeadLetterQueue

If this queue is configured with a dead-letter queue, this is the dead-letter queue settings.


Structs

TweetQueueProps

Initializer

import { TweetQueueProps } from 'cdk-tweet-queue'

const tweetQueueProps: TweetQueueProps = { ... }

Properties

Name Type Description
query string The twitter query string to stream.
secretArn string The SecretsManager secret that contains Twitter authentication credentials from https://apps.twitter.com/ with the following attributes (exact names): - consumer_key - consumer_secret - access_token_key - access_token_secret.
intervalMin number Polling interval in minutes.
retentionPeriodSec number Number of seconds for messages to wait in the queue for processing.
visibilityTimeoutSec number Number of seconds for messages to be invisible while they are processed.

queryRequired
public readonly query: string;
  • Type: string

The twitter query string to stream.


secretArnRequired
public readonly secretArn: string;
  • Type: string

The SecretsManager secret that contains Twitter authentication credentials from https://apps.twitter.com/ with the following attributes (exact names): - consumer_key - consumer_secret - access_token_key - access_token_secret.


intervalMinOptional
public readonly intervalMin: number;
  • Type: number
  • Default: 1min

Polling interval in minutes.

Set to 0 to disable polling.


retentionPeriodSecOptional
public readonly retentionPeriodSec: number;
  • Type: number
  • Default: 60 seconds

Number of seconds for messages to wait in the queue for processing.

After this time, messages will be removed from the queue.


visibilityTimeoutSecOptional
public readonly visibilityTimeoutSec: number;
  • Type: number
  • Default: 60 seconds

Number of seconds for messages to be invisible while they are processed.

Based on the amount of time it would require to process a single message.