# rss-nostr-lambda An AWS Lambda function that posts content found in an RSS feed to Nostr. ## Running Locally ### Local environment A [nix-shell development environment](https://nixos.wiki/wiki/Development_environment_with_nix-shell) is configured in this repo. You can use it by running `nix-shell` from within the project directory. This is the easiest way to get started working with this application. If you are not running [nix](https://nixos.wiki/wiki/Nix_package_manager) you will need to configure your environment manually. You will need the following dependencies: - [awscliv2](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html) is used for creating and updating resources in AWS. - [LocalStack](https://docs.localstack.cloud/getting-started/) is a service that mocks AWS services locally on your machine. - [Docker](https://docs.docker.com/engine/install/) is used by LocalStack under the hood. You'll need the Docker daemon up and running to use LocalStack. - [awscli-local](https://github.com/localstack/awscli-local) is a thin wrapper around the awscli which provides the `awslocal` command and allows you to call awscli commands without needing to provide the `--endpoint=http://localhost:xxxx` for LocalStack on each call. ### Makefile A [Makefile](https://www.gnu.org/software/make/manual/make.html) has been set up to bundle some of the commands used to set up and use this Lambda. ## Running in AWS This function runs in AWS Lambda and uses SSM to store state like the `last-run-time`. The function will read and write parameters in Parameter Store under the paths provided in the event spec below; be sure to [grant the proper permissions](https://docs.aws.amazon.com/systems-manager/latest/userguide/ps-integration-lambda-extensions.html) or this function will fail. The function requires the `AWS_REGION` environment variable to be set. This should already be set for you by AWS Lambda. ### Event Specification This Lambda function expects the following event to be passed in: `` { "feedUrl": String - The url of the RSS feed, "nostrNsecParam": String - The path of the SSM parameter holding the nsec, "lastRunTimeParam": String - The path of the SSM parameter holding the last run time } ``` ## Things to be awre of The following are not ideal and may be changed in the future: - This function uses a checkpointing algorithm based on the last run time. If the last run time is set to too long of a timeframe this function will timeout and misbehave. It's recommended to set the last run time to something recent -- like the last day or two. - This function does not generalize a way to provide the path to the needed data in the RSS feed. - This function hard-codes in the https://nostr.build URL. This is tightly coupled to using that service and provides no alternatives. - Further, if the function fails to upload the image to https://nostr.build it will simply remove the image entirely. There's room to improve this.