Persist
@klotho::persist
The persist capability is specified on a resource to provide the ability to store the data in the cloud.
When the persist annotation is used on a local resource, Klotho infers what Kind of persist is desired. Once the persist kind is deteremined, a default Type of technology is used to determine which technology is used to serve as the persist datastore. Klotho then reconfigures the local annotated resource to use the connection information from the created cloud datastore.
Directives
Directive | Type | Description |
---|---|---|
id | string | (Required) Specify the map id to use when generating a cloud resource. |
secret | boolean | (Optional) Only available on persist kind filesystem, default = false. Set to true to enable storing secrets |
environment_variables | Object | (Optional) Specified on an annotation to generate infrastructure and inject its characteristics as environment variables. For more information, see the persist concepts page. |
Environment Variable Directive
The environment variables directive allows the ability to specify a persist annotation that is not attached to a specific client or node, as well as retrieving characteistics of annotations that are attached to a client or node.
The directive takes a list of key-value pairs. The key specifies the environment variable name, which will be useable in the execution unit, while the value specifies the characteristic of the infrastructure the environment variable represents.
The value is structured as kind.allowed_value
, with the list of kinds and their corresponding allowed values below.
When the environment variables directive is specified on a persist annotation, the execution units containing the persist annotation will have the environment variables injected.
Below is an example of using the environment_variables
directive
/*
* @klotho::persist {
* id = "myRedisNode"
* [environment_variables]
* REDIS_NODE_HOST = "redis_node.host"
* REDIS_NODE_PORT = "redis_node.port"
* }
*/
Below is the list of allowed combinations of persist kinds and values available:
Kind | Allowed Values |
---|---|
ORM | connection_string |
Redis Node | host , port |
Redis Cluster | host , port |
Kind
Kind, is the general categorization of persist resources. Kinds are not provider specific, as they do not refer to any provider specific technology, and are determined based on the library used by the annotated resource. For example, a resource using sequalize would be categorized as persist kind ORM, whereas one using TypeScript fs
, would be persist kind Filesystem. You can learn more about persist kinds in the language specific persist documentation under API, for example NodeJs Persist
Type
The type specifies the actual technology used for the cloud datastore. Type is provider and persist kind specific.
Configuration
We support many different Kinds
of persist, and for each kind, we provide a variety of Types
of technologies to choose from.
This can be configured within the Klotho configuration.