cdk-tweet-queue


Namecdk-tweet-queue JSON
Version 2.0.43 PyPI version JSON
download
home_pagehttps://github.com/eladb/cdk-tweet-queue
SummaryDefines an SQS queue with tweet stream from a search
upload_time2022-06-16 00:28:55
maintainer
docs_urlNone
authorElad Ben-Israel<elad.benisrael@gmail.com>
requires_python~=3.7
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Tweet Queue for AWS CDK

This is an [AWS CDK](https://github.com/awslabs/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](https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html) and
sending all new tweets to an SQS queue.

Inspired by
[@jlhood](https://github.com/awslabs/aws-serverless-twitter-event-source/commits?author=jlhood)'s
[aws-serverless-twitter-event-source](https://github.com/awslabs/aws-serverless-twitter-event-source)

## Architecture

![](https://github.com/eladb/cdk-tweet-queue/raw/master/images/architecture.png)

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](https://developer.twitter.com/en/apply-for-access.html) for a Twitter
developer account, and obtain API keys through by defining a [new
application](http://twitter.com/oauth_clients/new).

The Twitter API keys are read by the poller from an [AWS Secrets
Manager](https://aws.amazon.com/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:
   ![](https://github.com/eladb/cdk-tweet-queue/raw/master/images/secretsmanager.png)
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.

```console
$ npm install cdk-tweet-queue
```

Add a `TweetQueue` to your CDK stack:

```python
import { TweetQueue } from 'cdk-tweet-queue';

const queue = new TweetQueue(this, 'TweetStream', {
  // this is the ARN of the secret you stored
  secretArn: '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
  intervalMin: 60,          // optional: polling interval in minutes
  retentionPeriodSec: 60,   // optional: queue retention period
  visibilityTimeoutSec: 60, // optional: queue visilibity timeout
});
```

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](https://github.com/projen/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.

```console
$ yarn integ:deploy
```

Don't forget to destroy:

```console
$ yarn integ:destroy
```

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

```console
yarn integ <command>
```

## License

Apache-2.0



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/eladb/cdk-tweet-queue",
    "name": "cdk-tweet-queue",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "~=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Elad Ben-Israel<elad.benisrael@gmail.com>",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/bd/5f/745bd0ad1d7d7b452c8a98df20fb5d5b5208973ce8cf050c58c6d40b2a57/cdk-tweet-queue-2.0.43.tar.gz",
    "platform": null,
    "description": "# Tweet Queue for AWS CDK\n\nThis is an [AWS CDK](https://github.com/awslabs/aws-cdk) construct library which\nallows you to get a feed of Twitter search results into an SQS queue. It works\nby periodically polling the freely available [Twitter Standard Search\nAPI](https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html) and\nsending all new tweets to an SQS queue.\n\nInspired by\n[@jlhood](https://github.com/awslabs/aws-serverless-twitter-event-source/commits?author=jlhood)'s\n[aws-serverless-twitter-event-source](https://github.com/awslabs/aws-serverless-twitter-event-source)\n\n## Architecture\n\n![](https://github.com/eladb/cdk-tweet-queue/raw/master/images/architecture.png)\n\n1. A CloudWatch Event Rule triggers the poller AWS Lambda function periodically\n2. The poller reads the last checkpoint from a DynamoDB table (if exists)\n3. The poller issues a Twitter search query for all new tweets\n4. The poller enqueues all tweets to an SQS queue\n5. The poller stores the ID of the last tweet into the DynamoDB checkpoint table.\n6. Rinse & repeat.\n\n## Twitter API Keys\n\nTo issue a Twitter search request, you will need to\n[apply](https://developer.twitter.com/en/apply-for-access.html) for a Twitter\ndeveloper account, and obtain API keys through by defining a [new\napplication](http://twitter.com/oauth_clients/new).\n\nThe Twitter API keys are read by the poller from an [AWS Secrets\nManager](https://aws.amazon.com/secrets-manager/) entry. The entry must contain\nthe following attributes: `consumer_key`, `consumer_secret`, `access_token_key`\nand `access_token_secret` (exact names).\n\n1. Create a new AWS Secrets Manager entry for your API keys\n2. Fill in the key values as shown below:\n   ![](https://github.com/eladb/cdk-tweet-queue/raw/master/images/secretsmanager.png)\n3. Store the key\n4. Obtain the ARN of the secret (you will need it soon).\n\n## Usage\n\nUse `npm` to install the module in your CDK project. This will also add it to\nyour `package.json` file.\n\n```console\n$ npm install cdk-tweet-queue\n```\n\nAdd a `TweetQueue` to your CDK stack:\n\n```python\nimport { TweetQueue } from 'cdk-tweet-queue';\n\nconst queue = new TweetQueue(this, 'TweetStream', {\n  // this is the ARN of the secret you stored\n  secretArn: 'arn:aws:secretsmanager:us-east-1:1234567891234:secret:xxxxxxxxx'\n\n  // twitter search query\n  // see https://developer.twitter.com/en/docs/tweets/search/guides/standard-operators\n  query: '#awscdk',\n\n  // optional properties\n  intervalMin: 60,          // optional: polling interval in minutes\n  retentionPeriodSec: 60,   // optional: queue retention period\n  visibilityTimeoutSec: 60, // optional: queue visilibity timeout\n});\n```\n\nNow, `queue` is an `sqs.Queue` object and can be used anywhere a queue is\naccepted. For example, you could process the queue messages using an AWS Lambda\nfunction by setting up an SQS event source mapping.\n\n## Development\n\nThe project is managed by [projen](https://github.com/projen/projen) and offers the following commands:\n\n* `yarn projen` - Synthesize the project configuration.\n* `yarn compile` - Compile all source code.\n* `yarn test` - Run all tests.\n* `yarn build` - Complie, test, and package the module.\n\n## Integration test\n\nThere 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.\n\n```console\n$ yarn integ:deploy\n```\n\nDon't forget to destroy:\n\n```console\n$ yarn integ:destroy\n```\n\nYou can also run any cdk command on the integration test application by running:\n\n```console\nyarn integ <command>\n```\n\n## License\n\nApache-2.0\n\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Defines an SQS queue with tweet stream from a search",
    "version": "2.0.43",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "b01a21c0e84994ffe3e8ec452c63b281",
                "sha256": "b0a9bba9df7341e41efb2609dc313736f28992c427ccefca950e6d13d4fa7256"
            },
            "downloads": -1,
            "filename": "cdk_tweet_queue-2.0.43-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b01a21c0e84994ffe3e8ec452c63b281",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.7",
            "size": 103723,
            "upload_time": "2022-06-16T00:28:53",
            "upload_time_iso_8601": "2022-06-16T00:28:53.057372Z",
            "url": "https://files.pythonhosted.org/packages/25/bb/46c8443f23f77810549302ab636876017b7550e6384b2c804b4f3d89f0dc/cdk_tweet_queue-2.0.43-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "01af20b33dc1da73143462145c9cb147",
                "sha256": "a2fce47fb4c1855df118d61908dda62523ad10a83380b615bbe5deea6c059366"
            },
            "downloads": -1,
            "filename": "cdk-tweet-queue-2.0.43.tar.gz",
            "has_sig": false,
            "md5_digest": "01af20b33dc1da73143462145c9cb147",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.7",
            "size": 105147,
            "upload_time": "2022-06-16T00:28:55",
            "upload_time_iso_8601": "2022-06-16T00:28:55.312194Z",
            "url": "https://files.pythonhosted.org/packages/bd/5f/745bd0ad1d7d7b452c8a98df20fb5d5b5208973ce8cf050c58c6d40b2a57/cdk-tweet-queue-2.0.43.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-06-16 00:28:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "eladb",
    "github_project": "cdk-tweet-queue",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cdk-tweet-queue"
}
        
Elapsed time: 0.40346s