Technical Documentation
Configuration
To configure the environment variables for use with render_cdk, you need to set the API_KEY environment variable. You can do this by creating a .env file in the root of your project with the following content:
API_KEY=rnd_xxxxXXXXxxxxXXXXxxxXX
Make sure to replace rnd_xxxxXXXXxxxxXXXXxxxXX with your actual Render API key.
Installation
Add render_cdk to your Cargo.toml:
[]
= "0.0.11"
- Alternatively, running at the
cargo add render_cdkroot of your project will also add render_cdk to your project.
Usage Examples
Here are basic examples of how to use the render_cdk crate to interact with Render Cloud:
1. Querying for Deployed Services
The following example demonstrates how to query deployed services base on specified criteria.
use *;
use *;
use main;
async
2. Using Simple .conf Files for Resource Provisioning
.conffiles offer a convenient alternative to programmatic resource provisioning, allowing you to define and manage resources through simple configuration settings.
Configuration File Example
The following is a sample configuration_ file. This will be used to provision a managed Postgres instance and a managed Redis instance.
-
[database]section specifies the configuration for a managed Postgres instance. -
The
nameanduserfields should be filled with the desired database name and user.enable_high_availabilityindicates whether high availability should be enabled.planspecifies the pricing plan for the instance, andversionindicates the Postgres version.
# The following is a sample configuration file.
# This will be used to provision a
# managed postgres instance and managed redis instance.
[database]
databaseName = "" # Replace with the desired database name
databaseUser = "" # Set to true to enable high availability
enableHighAvailability = false # Pricing plan for the database instance
plan = "starter"
version = "12" # Postgres version
name = ""
# The following portion enables <public> access.
cidrBlocks = [
{ cidrBlock = "0.0.0.0/0", description = "Everywhere" }
# { cidrBlock = "0.0.0.0/0", description = "Everywhere" },
# { cidrBlock = "0.0.0.0/0", description = "Everywhere" }
# Add more CIDR blocks here...
]
Note Blank fields will be autogenerated.
[redis]section specifies the configuration for a managed Redis instance.planspecifies the pricing plan for the instance.
[redis]
plan = "starter" # Pricing plan for the Redis instance`
Explanation
-
[database] Section:
-
name: The name of the Postgres database.
-
user: The user for the Postgres database.
-
enable_high_availability: Boolean value to enable or disable high availability for the database.
-
plan: The pricing plan for the Postgres instance. Options may include "starter", "standard", "premium", etc.
Note free plan will result in failed deployments.
-
version: The version of Postgres to be used.
-
-
[redis] Section:
-
plan: The pricing plan for the Redis instance. Options may include "free", "standard", "premium", etc.
Note free plan will result in failed deployments.
-
This configuration file allows you to easily set up managed database and caching services with specific plans and options suited to your project's needs.
use Conf;
3. Retrieve the Authorized User's Id
The Owner Id is used to tie the deployed resource to the Acting Service Principal/Render Account Owner.
use crate*;
use main;
async
4. Creating Services
The following examples shows how to deploy a static site.
use crate*;
use *;
use ;
use main;
async