This project provides an AWS Lambda that freshens the given API endpoint when new data is added to the S3 bucket. The function should be invoked from another Lambda like so:
url_payload = { "freshen_url": "https://api.trade.gov/v1/endpoint_goes_here/freshen.json?api_key="}
lambda_client.invoke(FunctionName="endpoint_freshen", InvocationType='Event', Payload=json.dumps(url_payload))
- This project is tested against Python 3.7+ in CircleCI.
- Make sure you have your Trade.gov API Admin Key handy. You need to be authorized as an admin in order to freshen the data.
git clone git@github.com:GovWizely/lambda-endpoint-freshen.git
cd lambda-endpoint-freshen
mkvirtualenv -p /usr/local/bin/python3.8 -r requirements-test.txt lambda-endpoint-freshen
If you are using PyCharm, make sure you enable code compatibility inspections for Python 3.7/3.8.
python -m pytest- Define the Trade.gov API Admin Key as an environment variable
export API_KEY=your_key. This will allow you to run the Lambda locally. - Define AWS credentials in either
config.yamlor in the [default] section of~/.aws/credentials. To use another profile, you can do something likeexport AWS_DEFAULT_PROFILE=govwizely. - Edit
config.yamlif you want to specify a different AWS region, role, and so on.
lambda invoke -v
In the AWS Lambda console, set up the API_KEY environment variable. Then you are ready to deploy:
lambda deploy --requirements requirements.txt