Defining resources
Resources
Azure resources are defined inside the resources array (ignore the $schema field, it provides the autocomplete functionalities in your IDE but is ignored at compile time)
{
"$schema": "https://hulk.cyncly-platform.com/schemas/main.json",
"team": "your team identifier",
"project": "Your project name",
"envs": {
"name": "NAME OF THE ENVIRONMENT",
"rg": "NAME OF THE RESOURCE GROUP",
"subscription": "NAME OF THE AZURE SUBSCRIPTION",
"abbr": "NAME OF THE ENVIRONMENT ABBREVIATION"
},
"resources": ["Here!"]
}
Modules
Modules are used to split your templates in multiple files. To define a module, include the path to the file you want to include inside your project.
Modules can only be defined inside the main.json file. If you try to nest modules the transpiler will exit with an error.
main.json
{
"$schema": "https://hulk.cyncly-platform.com/schemas/main.json",
"team": "argvengers",
"project": "demo",
"envs": [
{
"name": "prod",
"rg": "argvengerstools-prod-rg",
"subscription": "2020-prod",
"abbr": "prod",
}
],
"resources": [
{
"storage_account": {
"name": "safirststorage{env}",
"kind": "StorageV2",
"sku": "Standard_LRS"
}
}
],
"modules": ["./my-file.json"]
}
my-file.json
{
"$schema": "https://hulk.cyncly-platform.com/schemas/module.json",
"resources": [
{
"storage_account": {
"name": "sasecondstorage{env}",
"kind": "StorageV2",
"sku": "Standard_LRS"
}
}
]
}
At compile time, the main.json file would expand to this:
{
"$schema": "https://hulk.cyncly-platform.com/schemas/main.json",
"team": "your team identifier",
"project": "Your project name",
"envs": {
"name": "NAME OF THE ENVIRONMENT",
"rg": "NAME OF THE RESOURCE GROUP",
"subscription": "NAME OF THE AZURE SUBSCRIPTION",
"abbr": "NAME OF THE ENVIRONMENT ABBREVIATION"
},
"resources": [
{
"storage_account": {
"name": "safirststorage{env}",
"kind": "StorageV2",
"sku": "Standard_LRS",
"containers": []
}
},
{
"storage_account": {
"name": "sasecondstorage{env}",
"kind": "StorageV2",
"sku": "Standard_LRS",
"containers": []
}
}
]
}
Example
File structure
āāā main.json
āāā modules
āāā functions.json
āāā storage.json
main.json
{
"$schema": "https://hulk.cyncly-platform.com/schemas/main.json",
"team": "argvengers",
"project": "doc-basics-demo",
"envs": [
{
"name": "prod",
"rg": "argvengerstools-prod-rg",
"subscription": "2020-prod",
"abbr": "prod",
}
],
"resources": [],
"modules": ["modules/appservice.json", "storage.json"]
}
appservice.json
This file creates a consumption plan for linux and links a function app to it. Note that the function app has a reference to a storage account (this is required by Azure for syncing triggers and logging)
{
"$schema": "https://hulk.cyncly-platform.com/schemas/module.json",
"resources": [
{
"app_service_plan": {
"name": "plan-consump-{env}-eus",
"os": "linux",
"kind": "Consumption",
"type": "function_app"
}
},
{
"function_app": {
"name": "func-app-{env}-eus",
"@plan_name": "plan-consump-{env}-eus",
"@storage_account_name": "ststorage{env}",
"runtime": "dotnet"
}
}
]
}
storage.json
{
"$schema": "https://hulk.cyncly-platform.com/schemas/module.json",
"resources": [
{
"storage_account": {
"name": "ststorage{env}",
"kind": "StorageV2",
"sku": "Standard_LRS"
}
}
]
}
Output
To validate the project, run the synth command with the path to your main file:
$ hulk synth ./main.json --env prod
āļø Synthesizing schema from ./main.json...
⨠3 resources synthesized
1 storage_account
1 app
1 app_service_plan
Your deployment is configured for the following environment: [prod] argvengerstools-prod-rg
To see the generated Bicep, run the transpile command with the same path:
$ hulk transpile ./main.json --env prod
Found 2 module(s) in main.json
Found 2 resource(s) inside module: functions.json
Found 1 resource(s) inside module: storage.json
⨠Transpiled file written to: .hulk/main.bicep