Skip to main content

Tweet Queue for AWS CDK

This is an AWS CDK construct library which allows you to get a feed of Twitter search results into an SQS queue. It works by periodically polling the freely available Twitter Standard Search API and sending all new tweets to an SQS queue.

Inspired by @jlhood's aws-serverless-twitter-event-source

Architecture

  1. A CloudWatch Event Rule triggers the poller AWS Lambda function periodically
  2. The poller reads the last checkpoint from a DynamoDB table (if exists)
  3. The poller issues a Twitter search query for all new tweets
  4. The poller enqueues all tweets to an SQS queue
  5. The poller stores the ID of the last tweet into the DynamoDB checkpoint table.
  6. Rinse & repeat.

Twitter API Keys

To issue a Twitter search request, you will need to apply for a Twitter developer account, and obtain API keys through by defining a new application.

The Twitter API keys are read by the poller from an AWS Secrets Manager entry. The entry must contain the following attributes: consumer_key, consumer_secret, access_token_key and access_token_secret (exact names).

  1. Create a new AWS Secrets Manager entry for your API keys
  2. Fill in the key values as shown below:
  3. Store the key
  4. Obtain the ARN of the secret (you will need it soon).

Usage

Use npm to install the module in your CDK project. This will also add it to your package.json file.

$ npm install cdk-tweet-queue

Add a TweetQueue to your CDK stack:

from cdk_tweet_queue import TweetQueue


queue = TweetQueue(self, "TweetStream",
    # this is the ARN of the secret you stored
    secret_arn="arn:aws:secretsmanager:us-east-1:1234567891234:secret:xxxxxxxxx",

    # twitter search query
    # see https://developer.twitter.com/en/docs/tweets/search/guides/standard-operators
    query="#awscdk",

    # optional properties
    interval_min=60,  # optional: polling interval in minutes
    retention_period_sec=60,  # optional: queue retention period
    visibility_timeout_sec=60
)

Now, queue is an sqs.Queue object and can be used anywhere a queue is accepted. For example, you could process the queue messages using an AWS Lambda function by setting up an SQS event source mapping.

Development

The project is managed by projen and offers the following commands:

  • yarn projen - Synthesize the project configuration.
  • yarn compile - Compile all source code.
  • yarn test - Run all tests.
  • yarn build - Complie, test, and package the module.

Integration test

There is also an integration test that can be executed by running the following commands. You will need to set the TWEET_QUEUE_SECRET_ARN environment variable in order for the test to be able to use your Twitter API keys.

$ yarn integ:deploy

Don't forget to destroy:

$ yarn integ:destroy

You can also run any cdk command on the integration test application by running:

yarn integ <command>

License

Apache-2.0

Metadata

Release files for cdk-tweet-queue 2.0.964

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cdk-tweet-queue 2.0.964
File Size Uploaded
cdk_tweet_queue-2.0.964.tar.gz 123.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cdk-tweet-queue 2.0.964
File Interpreter ABI Platform
cdk_tweet_queue-2.0.964-py3-none-any.whl Python 3 none any Details

Total release size: 245.1 kB

Release files / cdk_tweet_queue-2.0.964.tar.gz

Download URL cdk_tweet_queue-2.0.964.tar.gz
Size 123.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8c7fd1e898cab31c90f15e617dfa7da4972aea59f7d1b410fac680350d825c31
BLAKE2b-256 checksum
How to use checksums
c926ad2d334e0611f540e27f863e603eee6a3d7643478206ea5d05bf01a1391d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.14.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release files / cdk_tweet_queue-2.0.964-py3-none-any.whl

Download URL cdk_tweet_queue-2.0.964-py3-none-any.whl
Size 121.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
797f2c99e1ea120fd05e009b8caf84a950e95357b920ea8f192f0c0f9ff39b6d
BLAKE2b-256 checksum
How to use checksums
f77c885477d41158d04866f1454aa8cadace10b1d427f972372af071f647ac0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.14.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.964 This release

2 release files

2.0.99

2 release files

2.0.98

2 release files

2.0.97

2 release files

2.0.96

2 release files

2.0.95

2 release files

2.0.89

2 release files

2.0.88

2 release files

2.0.87

2 release files

2.0.86

2 release files

2.0.85

2 release files

2.0.84

2 release files

2.0.83

2 release files

2.0.82

2 release files

2.0.81

2 release files

2.0.80

2 release files

2.0.79

2 release files

2.0.78

2 release files

2.0.77

2 release files

2.0.76

2 release files

2.0.75

2 release files

2.0.74

2 release files

2.0.73

2 release files

2.0.72

2 release files

2.0.71

2 release files

2.0.62

2 release files

2.0.61

2 release files

2.0.60

2 release files

2.0.59

2 release files

2.0.58

2 release files

2.0.57

2 release files

2.0.56

2 release files

2.0.55

2 release files

2.0.54

2 release files

2.0.53

2 release files

2.0.52

2 release files

2.0.51

2 release files

2.0.50

2 release files

2.0.49

2 release files

2.0.48

2 release files

2.0.47

2 release files

2.0.46

2 release files

2.0.45

2 release files

2.0.44

2 release files

2.0.43

2 release files

2.0.42

2 release files

2.0.41

2 release files

2.0.40

2 release files

2.0.39

2 release files

2.0.38

2 release files

2.0.28

2 release files

2.0.27

2 release files

2.0.26

2 release files

2.0.25

2 release files

2.0.24

2 release files

2.0.23

2 release files

2.0.22

2 release files

2.0.21

2 release files

2.0.20

2 release files

2.0.19

2 release files

2.0.18

2 release files

2.0.17

2 release files

2.0.16

2 release files

2.0.15

2 release files

2.0.14

2 release files

2.0.13

2 release files

2.0.9

2 release files

2.0.8

2 release files

2.0.7

2 release files

2.0.6

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.99

2 release files

1.0.98

2 release files

1.0.97

2 release files

1.0.96

2 release files

1.0.95

2 release files

1.0.94

2 release files

1.0.93

2 release files

1.0.92

2 release files

1.0.91

2 release files

1.0.90

2 release files

1.0.89

2 release files

1.0.88

2 release files

1.0.78

2 release files

1.0.77

2 release files

1.0.76

2 release files

1.0.75

2 release files

1.0.74

2 release files

1.0.73

2 release files

1.0.72

2 release files

1.0.71

2 release files

1.0.70

2 release files

1.0.69

2 release files

1.0.68

2 release files

1.0.67

2 release files

1.0.66

2 release files

1.0.65

2 release files

1.0.64

2 release files

1.0.63

2 release files

1.0.62

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page