Azion IaC

The azion.config.js file is an IaC configuration file created during the application’s build process, based on the chosen preset, and serves as the source of truth for the configuration. Each preset provides a set of default settings, which can be replaced by the user. If the file is deleted, the default configuration will be recreated the next time the build process is triggered.

The configurations set by this file include:

  • Build Configurations
  • Origins
  • Cache Settings
  • Rules Engine
  • Network List
  • Purge Settings

The following tables explain the properties of this configuration file.


build

PropertyTypeDescriptionExpected values
builderStringThe build tool to useesbuild or webpack
presetObjectThe preset to useProperty:
name (String)
entryStringEntry point for your application
polyfillsBooleanWhether to include Node.js polyfills
workerBooleanWhether to build an owner worker
customObjectCustom build configuration
memoryFSObjectMemory file system configurationProperties:
InjectionDirs (Array)
RemovePathPrefix (String)

domain

PropertyTypeExpected valuesError message
namestring
cnameAccessOnlyboolean
cnamesarray
edgeApplicationIdnumber
edgeFirewallIdnumber
digitalCertificateIdstring, nulllets_encrypt or null
mtlsobject
mtls -> verificationstringenforce or permissive
mtls -> trustedCaCertificateIdnumber
mtls -> crlListarray

origin

PropertyTypeExpected valuesError message
namestringThe ‘name’ field must be a string
typestringsingle_origin (default)
load_balancer
live_ingest**
object_storage
The ‘type’ field must be a string
bucketstring, nullThe ‘bucket’ field must be a string or null
prefixstring, nullThe ‘prefix’ field must be a string or null
addressesarrayThe ‘address’ field must be a string
hostHeaderstringThe ‘hostHeader’ field must be a string
protocolPolicystringpreserve (default)
https
http
The ‘protocolPolicy’ field must be a string
hostHeaderstringThe ‘hostHeader’ field must be a string
connectionTimeoutnumberThe ‘connectionTimeout’ field must be a number
timeoutBetweenBytesnumberThe ‘timeoutBetweenBytes’ field must be a number
redirectionbooleanThe ‘redirection’ field must be a boolean
hmacobjectThe ‘hmac’ field must be an object
hmac -> regionstringThe ‘region’ field must be a string
hmac -> accessKeystringThe ‘accessKey’ field must be a string
hmac -> secretKeystringThe ‘secretKey’ field must be a string
bucketstring, nullThe ‘bucket’ field must be a string or null
prefixstring, nullThe ‘prefix’ field must be a string or null
additionalPropertiesbooleanNo additional properties are allowed in origin item objects

cache

PropertyTypeExpected valuesError message
namestringThe ‘name’ field must be a string
stalebooleanThe ‘stale’ field must be a boolean
queryStringSortbooleanThe ‘queryStringSort’ field must be a boolean
methods -> postbooleanThe ‘post’ field must be a boolean
methods -> optionsbooleanThe ‘options’ field must be a boolean
methods -> additionalPropertiesbooleanNo additional properties are allowed in the ‘methods’ object
browser -> maxAgeSecondsnumber OR string (mathematical expression)0 ≤ value ≥ 31536000The ‘maxAgeSeconds’ field must be a number or a valid mathematical expression
browser -> additionalPropertiesbooleanNo additional properties are allowed in the ‘browser’ object
browser -> requiredarrayThe ‘maxAgeSeconds’ field is required in the ‘browser’ object
edge -> maxAgeSecondsnumber OR string (a mathematical expression)60 ≤ value ≥ 31536000The ‘maxAgeSeconds’ field must be a number or a valid mathematical expression
edge -> additionalPropertiesbooleanNo additional properties are allowed in the ‘edge’ object
edge -> requiredarrayThe ‘maxAgeSeconds’ field is required in the ‘edge’ object

rules

Request rules

PropertyTypeError message
namestringThe ‘name’ field must be a string
matchstringThe ‘match’ field must be a string
setOrigin -> namestringThe ‘name’ field must be a string
setOrigin -> typestringThe ‘type’ field must be a string
setOrigin -> additionalPropertiesbooleanNo additional properties are allowed in the ‘setOrigin’ object
setOrigin -> requiredarrayThe ‘name or type’ field is required in the ‘setOrigin’ object
behavior -> rewritefunctionThe behavior of the rewrite
setHeadersstring, nullThe ‘setHeaders’ field must be a string or null
forwardCookiesboolean, nullThe ‘forwardCookies’ field must be a boolean or null
setCookiestring, nullThe ‘setCookie’ field must be a string or null
deliverboolean, nullThe ‘deliver’ field must be a boolean or null
runFunction -> pathstringThe ‘path’ field must be a string
runFunction -> namestring, nullThe ‘name’ field can be a string or null
runFunction -> additionalPropertiesbooleanNo additional properties are allowed in the ‘runFunction’ object
runFunction -> requiredarrayThe ‘path’ field is required in the ‘runFunction’ object
cachestring OR objectThe ‘cache’ field must be either a string or an object with specified properties
cache -> name (when cache is an object)stringThe ‘name’ field must be a string
cache -> browser_cache_settings_maximum_ttl (when cache is an object)number, nullThe ‘browser_cache_settings_maximum_ttl’ field must be a number or null
cache -> cdn_cache_settings_maximum_ttl (when cache is an object)number, nullThe ‘cdn_cache_settings_maximum_ttl’ field must be a number or null
cache -> additionalProperties (when cache is an object)booleanNo additional properties are allowed in the cache object
cache -> required (when cache is an object)arrayThe ‘name’ field is required in the cache object
redirectTo301stringThe ‘redirectTo301’ field must be a string
enableGZIPbooleanThe ‘enableGZIP’ field must be a boolean
redirectTo302stringThe ‘redirectTo302’ field must be a string
filterCookiestringThe ‘filterCookie’ field must be a string
variablestringThe ‘variable’ field must be a string
bypassCachebooleanThe ‘bypassCache’ field must be a boolean
redirectHttpsbooleanThe ‘redirectHttps’ field must be a boolean

Response rules

PropertyTypeError message
namestringThe ‘name’ field must be a string
descriptionstringThe ‘description’ field must be a string
activebooleanThe ‘active’ field must be a boolean
matchstringThe ‘match’ field must be a string
variablestringThe ‘variable’ field must be a string
behavior -> setCookiestring, nullThe ‘setCookie’ field must be a string or null
behavior -> setHeadersarray of stringsEach item in ‘setHeaders’ must be a string
behavior -> deliverboolean, nullThe ‘deliver’ field must be a boolean or null
behavior -> capture -> matchstringThe ‘match’ field must be a string
behavior -> capture -> capturedstringThe ‘captured’ field must be a string
behavior -> capture -> subjectstringThe ‘subject’ field must be a string
behavior -> enableGZIPboolean, nullThe ‘enableGZIP’ field must be a boolean or null
behavior -> filterCookiestring, nullThe ‘filterCookie’ field must be a string or null
behavior -> filterHeaderstring, nullThe ‘filterHeader’ field must be a string or null
behavior -> runFunction -> pathstringThe ‘path’ field must be a string
behavior -> runFunction -> namestring, nullThe ‘name’ field can be a string or null
behavior -> redirectTo301string, nullThe ‘redirectTo301’ field must be a string or null
behavior -> redirectTo302string, nullThe ‘redirectTo302’ field must be a string or null

network list

PropertyTypeError message
idnumberThe ‘id’ field must be a number
listTypestringThe ‘listType’ field must be a string
listContentarrayThe ‘listContent’ field must be an array of strings

purge

PropertyTypeExpected valuesError message
typestringurl, cachekey, wildcard
urlsarray
methodstring delete
layerstringedge_caching, l2_caching

For further information, access azion.config.js schema in the Azion Lib repository.


Example

Here’s an example of an implementation of the azion.config.js file:

import { defineConfig } from 'azion';
const config = defineConfig({
domain: {
name: 'example.com',
cnameAccessOnly: false,
cnames: ['www.example.com', 'cdn.example.com'],
Id: 12345,
edgeFirewallId: 67890,
digitalCertificateId: null,
mtls: {
verification: 'enforce',
trustedCaCertificateId: 98765,
},
},
origin: [
{
name: 'My Origin',
type: 'single_origin',
addresses: [
{
address: 'origin.example.com',
weight: 100,
},
],
protocolPolicy: 'https',
},
],
cache: [
{
name: 'Default Cache',
browser: {
maxAgeSeconds: 3600,
},
edge: {
maxAgeSeconds: 7200,
},
},
],
rules: {
request: [
{
name: 'Example Rule',
match: 'path',
behavior: {
setOrigin: {
name: 'My Origin',
type: 'single_origin',
},
},
},
],
},
purge: [
{
type: 'url',
urls: ['https://example.com/path/to/purge'],
method: 'delete',
layer: 'edge_caching',
},
],
});

Contributors