This AWS SAM CloudFormation template creates a Lambda function that periodically calls a cron.php on a Nextcloud server.
| Parameter | Description | Default Value |
|---|---|---|
| WebCronUrl | The URL of the cron.php on your server. | - |
| WebCronRate | Web cron rate. | rate(5 minutes) |
You need to setup the following tools.
- AWS CLI
- AWS SAM
The following steps are examples for Mac OS.
You have to have AWS CLI to use AWS SAM command.
See also https://brew.sh to install brew command.
brew install awscliCreate Access key on AWS console then configure the AWS credentials.
aws configureYou can check your configuration by executing the following command.
aws configure listSee more details in the following URL. https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
https://aws.amazon.com/serverless/sam/
Example for Mac OS:
brew tap aws/tap
brew install aws-sam-clihttps://github.com/pyenv/pyenv#installation
brew install pyenv pyenv-virtualenv
eval $(pyenv init -)
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrccd cfn-nextcloud-webcron
pyenv install 3.8.5
pyenv virtualenv 3.8.5 cfn-nextcloud-webcron
pyenv local cfn-nextcloud-webcronYou'll asked parameters during the sam deploy --guided command interactivelly.
sam build
sam deploy --guidedHere is an example of the sam deploy --guided command.
Once you save the config in the file (samconfig.toml by default), all values are stored in the toml file. Then you don't need to use --guided option from next time.
$ sam deploy --guided
Configuring SAM deploy
======================
Looking for config file [samconfig.toml] : Not found
Setting default arguments for 'sam deploy'
=========================================
Stack Name [sam-app]: nextcloud-webcron
AWS Region [ap-northeast-1]:
Parameter WebCronUrl []: https://your.nextcloud.server/cron.php
Parameter WebCronRate [rate(5 minutes)]:
#Shows you resources changes to be deployed and require a 'Y' to initiate deploy
Confirm changes before deploy [y/N]:
#SAM needs permission to be able to create roles to connect to the resources in your template
Allow SAM CLI IAM role creation [Y/n]:
Save arguments to configuration file [Y/n]:
SAM configuration file [samconfig.toml]:
SAM configuration environment [default]:
...
Previewing CloudFormation changeset before deployment
======================================================
Deploy this changeset? [y/N]:
If you don't need the function, you can delete all AWS resources using the following command.
You have to specify the same stack name with sam deploy command
aws cloudformation delete-stack --stack-name nextcloud-webcroncd cfn-nextcloud-webcron
pyenv install 3.8.5
pyenv virtualenv 3.8.5 cfn-nextcloud-webcron
pyenv local cfn-nextcloud-webcron
pip install -r webcron/requirements.txt
pip install -r tests/requirements.txtpython -m pytest tests