Init Bundle
Available since the 2411 release.
Init Bundle is a simple approach to creating configuration resources when starting Aidbox.
It is equivalent to just executing Bundle in Aidbox using POST /fhir. There are some differences:
- It is executed before the internal HTTP server starts, and before the health check response.
- Unsuccessful execution of the init bundle of type transaction prevents Aidbox from starting.
- Unsuccessful execution of the init bundle of type batch triggers warnings in the log; Aidbox continues the startup process.
- Aidbox startup will be interrupted if the specified file is unavailable or is not a valid bundle resource of transaction or batch type.
- Only JSON format is supported.
Usage
Specify BOX_INIT_BUNDLE env. The value must be an URL.
BOX_INIT_BUNDLE=<URL>
Examples of URLs:
file:///tmp/bundle.jsonhttps://storage.googleapis.com/<BUCKET_NAME>/<OBJECT_NAME>
Example
If a Bundle file is created at /tmp/bundle.json:
{
"type": "batch",
"resourceType": "Bundle",
"entry": [
{
"request": {
"method": "POST",
"url": "/Observation",
"ifNoneExist": "_id=o1"
},
"resource": {
"id": "o1",
"code": {
"text": "text"
},
"status": "final",
"effectiveDateTime": "2000-01-01"
}
}
]
}
Aidbox will apply it if the BOX_INIT_BUNDLE is set to:
BOX_INIT_BUNDLE=file:///tmp/bundle.json
Hints
-
First, check that Aidbox handles the Bundle as it should using
POST /fhir. Try to post it several times to make sure it is idempotent. Then add it toBOX_INIT_BUNDLE. -
Note that the Aidbox format is not supported.
-
Aidbox handles an
idin the body of the POST request. That's why posting the resource with an id twice will cause anduplicate keyerror. Use conditional create or update for that. -
Most resources support
PUTfor idempotent updates inside an init bundle. Exception:AidboxTopicDestinationis immutable and rejectsPUT/PATCH(also inside bundles). Use a conditional create —POSTwithifNoneExist=_id=<id>— so the entry is a no-op when the resource already exists and creates it on the first run:{ "request": { "method": "POST", "url": "AidboxTopicDestination", "ifNoneExist": "_id=<id>" }, "resource": { "resourceType": "AidboxTopicDestination", "id": "<id>", "...": "..." } }To change configuration of an already-created destination, delete it manually and let the next bundle run recreate it — see Updating a TopicDestination.