Loads currency rates from a reliable source and creates, uploads a JSON representation to S3, and pushes the file to the currency-file github repo.
The S3 file is published to http://currency.prebid.org/latest.json. The github file is hosted at https://cdn.jsdelivr.net/gh/prebid/currency-file@1/latest.json.
$ git clone https://github.com/prebid/currency-file-generator.git
$ cd currency-file-generator
$ npm install
$ npm run test
src/currencyRatesFileGen.js
- FilecurrencyRatesFilesGen.handler
- Handler
- Get the login/password from someone who has it
- Update lambda function prebidCurrencyRatesFileAlerter from src/prebidCurrencyRatesFileAlerter.js
- To update the prebidCurrencyRatesFileGenerator lambda:
- clone the git repo and make/test your changes locally
- copy src/currencyRatesFileGen.js src/ajax.js src/shell.js to the top level of your local repo dir
- the test node_modules aren't needed, so
rm -rf node_modules
andnpm install --production
- zip -r currency-gen.zip currencyRatesFileGen.js ajax.js shell.js serverless.yml node_modules
- aws s3 cp currency-gen.zip s3://currency-generation-code
- go to the AWS lambda UI and upload https://s3.amazonaws.com/currency-generation-code/currency-gen.zip
- in Basic settings make sure that Handler is set to
currencyRatesFileGen.downloadPublish
- in AWS lambda UI add a corresponding layer that provides git support from https://github.com/lambci/git-lambda-layer (
arn:aws:lambda:us-east-1:553035198032:layer:git-lambda2:7
as of now) - make sure the environment variables are set correctly
- remove currencyRatesFileGen.js, ajax.js, and shell.js from the top level of your local repo dir
Note that you'll want to raise the timeout to 1.5 minutes.