This script works with USD only.
This project does 3 things:
- Deposits money into Coinbase Pro via ACH bank account
- Purchases cryptocurrencies on Coinbase Pro
- (Optionally) Deploys the script to AWS Lambda for you via Terraform
This project does not:
- Set up scheduling (when the script should run)
- Take responsibility for your funds
- Force you to use any sort of infrastructure
If you deploy to AWS, you can automatically execute the Lambda on a schedule by using CloudWatch Events which is akin to cron on AWS. Not included.
Or, you can decide to run the script locally under a cronjob. Not included.
Both are excellent ways to automatically set up purchases! The reason why I didn't include that in this project is because if you're smart enough to use this script, you probably want to customize exactly when your deposits/purchases occur.
Configurations live in config/
. There are 2 sets of configurations, local
and prod
.
local
configurations will be loaded when you execute from your development environment.
prod
configurations will be loaded when running as a Lambda in AWS.
Terraform will automatically copy config/prod_config.json
and config/prod_creds.json
to AWS
Secrets Manager. You can change the configurations in AWS Secrets Manager at any time by logging
into the AWS console.
config/local_config.json
= if running locallyconfig/prod_config.json
= if deploying to AWS
If you only want to deposit money but NOT purchase, set isDepositOnly
to true
.
The script will automatically deposit depositAmount
of USD into your Coinbase Pro account from
an ACH bank account every time the script runs. Other deposit methods are not supported.
Set this to 0
if you don't want to deposit anything.
You can add as many purchases as you want under the purchases
list. The script does not require that
the depositAmount
add up to the amount of crypto you want to purchase. i.e. sum(purchases) != depositAmount
The script only checks if you have enough money in your Coinbase Pro account to make the purchase. If so, your
cryptocurrencies will be purchased.
config/local_creds.json
= if running locallyconfig/prod_creds.json
= if deploying to AWS
You will need to set your Coinbase Pro API credentials for your account here.
When you run locally with ./runapp.sh
, the app reads from the local
config files in config/
.
You can set your Coinbase Pro credentials, deposit amount, and coins you wish to purchase in the
config/local_*.json
files.
When you deploy to AWS, the config/prod_*.json
files are copied into AWS Secrets Manager. The source code
in src/
and the Python dependencies for the Pipenv virtualenv are zipped into an archive and uploaded to S3.
Note that the Lambda will NOT run on its own when you deploy via Terraform.
You will need to install:
- Python3
- Pipenv
Once installed, run:
pipenv install
Execute:
./runapp.sh
Execute:
./runtests.sh
You will need to install the AWS CLI and set up credentials in your environment.
You will also need to install Terraform.
The Terraform files live in terraform/
. To deploy everything, simply do:
cd terraform
terraform init
terraform plan
terraform apply
This will deploy:
- (1) S3 bucket
- (1) S3 object containing source code
- (1) IAM execution role
- (2) AWS Secret Manager secrets for configuration
- (1) Lambda function
Note that when you do this, the script will NOT run automatically. You must set up your own scheduling.
cd terraform
terraform plan -destroy
terraform apply -destroy