This application retrieves current exchange rates from the European Central Bank's SDMX API and sends them to an e-mail in Excel spreadsheet. If today's exchange rates are not yet available, the ones from the last workday will be returned.
You can deploy it to Google Cloud Run or run it locally.
Firstly you need to edit the config.json file, which contains the following parameters:
target_email_address
: E-mail address the report will be sent tosender_email_address
: E-mail address the report will be sent fromsender_email_smtp_address
: Sender's SMTP addresssender_email_smtp_port
: Sender's SMTP portuse_locally
:true
when running the application locally,false
when deploying on cloudcurrencies
: list of currencies that you are interested in (e.g. CZK, HUF); by default this is filled with all EU currenciesgcp_project_id
: Google Cloud project ID
In any case, you need to enable Google Cloud Secret Manager and Cloud Logging. To deploy the application to GCP, you also need to enable Cloud Run and Artifact Registry.
Password for the sender's e-mail should be stored in Secret Manager under the name email_password
and the service account under which the service is deployed needs to have the Secret Manager Secret Accessor permission.
All application logs will be sent to Cloud Logging.
- Use the package manager pip to install requirements.
pip install -r requirements.txt
- Set parameter
use_locally
inconfig.json
totrue
. - Export a JSON file with service account credentials from GCP. Put it in the main directory and name it
service_account.json
. - Run:
python main.py
-
Set parameter
use_locally
inconfig.json
tofalse
. -
Build docker image:
docker build .
- Push the image to Artifact Registry and use it to create the Cloud Run service. More information about pushing to Artifact registry can be found here. Do not include
service_account.json
in the image - credentials will be determined automatically. - Invoke the service with a POST HTTP request (use Cloud Scheduler to do it periodically).