Web application on SourceCraft Sites and Yandex Cloud Functions
This guide demonstrates an example of deploying a simple web application using various services and tools:
- Frontend: Static website on SourceCraft Sites.
- Backend: Yandex Cloud Functions cloud function combined with a Yandex API Gateway gateway.
- Storing and working with code: SourceCraft repository.
- Creating Yandex Cloud resources: SourceCraft CI/CD and SourceCraft service connections to Yandex Cloud.
This web application is suitable for development and prototyping, or for a pet project. Advantages of this approach:
- There is no need to set up a virtual machine or a server for either the frontend or the backend.
- Free hosting on SourceCraft Sites with HTTPS access (no need to upload your own TLS certificate).
- The free tier for Yandex Cloud Functions and Yandex API Gateway allows you to use them at no cost under light workloads.
- Free access to SourceCraft features for working with code and CI/CD under the SourceCraft Free pricing plan.
Note
A web application (website) is published based on files hosted in a public repository belonging to a public SourceCraft organization.
You can confirm ownership of a SourceCraft Sites website in Yandex Webmaster. For more information, see Questions about SourceCraft.
To create a web app:
- Get ready to work.
- Clone (
git clone https://git@git.sourcecraft.dev/examples/sourcecraft-sites-web-app.git) or fork the repository into your organization on SourceCraft. - Create a service connection named
default-service-connection. - Manually run the
create-resourcesworkflow on themasterbranch. - Test your application.
If you no longer need the resources you have created, delete them and unpublish the website.
Getting started
Required paid resources
The cost of web application infrastructure support includes:
- Cost of using the gateway (see Yandex API Gateway pricing).
- Cost of using a cloud function (Yandex Cloud Functions pricing).
Testing the application
To open the application, navigate to the following URL in your browser: https://<organization_slug>.sourcecraft.site/<repository_name>. If everything was set up correctly, you will see an input field for a name and a button on the page that opens. Enter a name and click the button; a greeting line should then appear below.
Deleting Yandex Cloud resources
You can delete the resources (the gateway and the cloud function) using one of the following methods:
- Manually in the Yandex Cloud console (delete the function, delete the API gateway).
- Manually run the
delete-resourcesworkflow in the repository.
Unpublishing a website
To unpublish a website, simply perform one of the following actions:
- Making a repository or organization private.
- Removing the
.sourcecraft/sites.yamlfile from the repository's main branch.
Useful links
Connecting to a Managed Service for YDB database from a Python function in Yandex Cloud Functions