@boostercloud/serialize-config
v0.1.2
Published
Serialize your Booster Framework configuration
Downloads
7
Maintainers
Keywords
Readme
Serialize Config for Booster Framework Injectable
Welcome to the Serialize Config component for Booster Framework's Injectable! This indispensable tool streamlines your infrastructure automation by serializing the Booster Config object into a JSON file. It allows for easy extraction of names and type information for your project's commands, events, entities, read models, and more. Serialize Config is perfect for use with automation tools like Terraform, enhancing your development workflow.
- Features
- Quick Start
- Running Serialize Config
- Example: Leveraging Serialize Config for automatic Terraform generation
- Getting Help
- Contributing
- License
Features
- Automation Friendly: Facilitates infrastructure as code (IaC) practices by making your Booster project's configuration accessible in JSON format.
- Comprehensive Project Insights: Gain detailed insights into your project's commands, events, entities, read models, and more.
- Seamless Integration: Integrate Serialize Config into your Booster project effortlessly to enhance your infrastructure automation.
Quick Start
Follow these steps to integrate Serialize Config into your Booster project:
Installation
First, install Serialize Config via npm by running the following command in your project directory:
npm install @boostercloud/serialize-config
Modify Your Config File
To ensure Serialize Config works seamlessly with your Booster project, modify your config file (src/config/config.ts
) to include the injectable configuration for serialize config like so:
// your-app/src/config/config.ts
import * as SerializeConfig from '@boostercloud/serialize-config'
Booster.configure('YOUR_ENVIRONMENT_NAME', (config: BoosterConfig): void => {
// ... other config
config.injectable = {
commands: [SerializeConfig.command],
}
})
Running Serialize Config
Once you've set up Serialize Config in your Booster project, executing it is straightforward. To generate the serialized Booster configuration JSON file, run the following command from your project's root directory:
boost serialize-config -e YOUR_ENVIRONMENT_NAME
This command provides you with additional options and usage information for the Serialize Config command.
By default, the output JSON file will be saved to .booster/infra-config.json
within your project directory. If you wish to specify a different output location, you can use the --output
flag followed by your desired path. Here's an example command that demonstrates this:
boost serialize-config -e local --output path/to/your/custom-config.json
This flexibility allows you to integrate the serialized configuration seamlessly into your infrastructure automation workflows.
Example: Leveraging Serialize Config for automatic Terraform generation
To illustrate how Serialize Config can be used to preconfigure resources with Terraform, let’s consider a simplified example from a JSON output, focusing on a specific section named CartReadModel
. This model outlines the structure and data types of a shopping cart in an e-commerce application. Here’s a snippet highlighting key properties:
"CartReadModel": {
"properties": [
{
"name": "id",
"typeInfo": {
"name": "UUID",
"typeGroup": "Class",
"isNullable": false
}
},
{
"name": "testProperty",
"typeInfo": {
"name": "number",
"typeGroup": "Number",
"isNullable": false
}
},
{
"name": "cartItems",
"typeInfo": {
"name": "CartItem[]",
"typeGroup": "Array",
"isNullable": false
}
},
{
"name": "shippingAddress",
"typeInfo": {
"name": "Address",
"typeGroup": "Class",
"isNullable": true
}
}
]
}
This JSON snippet includes an identifier (id
), a test property (testProperty
), an array of cart items (cartItems
), and a shipping address (shippingAddress
). Each property has associated type information, such as UUID
for the id
or CartItem[]
for the list of items in the cart, indicating the expected data structure and types for these fields.
Using the CartReadModel JSON for Terraform Preconfiguration
Given the CartReadModel example, you can use this structured information to preconfigure Terraform resources, ensuring that your infrastructure aligns with the application’s data models. Here’s how to approach this:
Define Database Schema: Extract key information from the CartReadModel to define the schema of a database table. Each property in the JSON maps to a column in the table, with the typeInfo indicating the data type.
Terraform Resource Definition: Use the schema information to create a Terraform resource definition for a database table. For instance, if using AWS DynamoDB, define attributes and their types based on the model’s properties.
Example Terraform configuration for the CartReadModel
resource "aws_dynamodb_table" "cart_table" {
name = "Cart"
hash_key = "id"
billing_mode = "PROVISIONED"
attribute {
name = "id"
type = "S" # String type for UUID
}
attribute {
name = "testProperty"
type = "N" # Number
}
...
}
By following these steps, developers can leverage the detailed structure provided by Serialize Config to ensure their Terraform configurations accurately reflect the application’s data models, streamlining the infrastructure setup and maintenance process.
Getting Help
Should you face any challenges or have questions regarding Serialize Config, please consult the Booster Framework documentation or join our vibrant community on the Discord server (link available in the docs). Our community and contributors are eager to assist.
Contributing
Contributions to Serialize Config are warmly welcomed. Whether it's enhancing documentation, adding features, or reporting issues, your input helps us improve. Please refer to our contributing guidelines for more information.
License
Serialize Config is open-source software licensed under the Apache License 2.0.
Dive into the world of efficient infrastructure automation with Serialize Config and elevate your Booster Framework projects to new heights!