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
You can confirm ownership of a SourceCraft Sites website in Yandex Webmaster
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
nameddefault-service-connection. - Manually run
thecreate-resourcesworkflow on themasterbranch. - Test your application.
If you no longer need the resources you have created, delete them and unpublish the website.
Getting started
-
Sign up for Yandex Cloud and create a billing account:
- Navigate to the management console
and log in to Yandex Cloud or create a new account. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVEorTRIAL_ACTIVEstatus. If you do not have a billing account, create one and link a cloud to it.
If you have an active billing account, you can create or select a folder for your infrastructure on the cloud page
. - Navigate to the management console
- Authenticate in SourceCraft on the service home page
or sign up .
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 thedelete-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