Configure services programmatically using ops.json
ops.json
file allows you to declaratively define configuration for your services.
In your service configuration ops.json
, you can define
ops.json
file to your Github repositoryops.json
ops.json
configuration.ops.json
dependencies
are provisioned first. See herepreviews.dependencies
are provisioned in the order defined. See hereinit
array are executed in order. These jobs must start and finish one after the other successfully. See herecron
are started. See herepreviews.workers
are started. See hereinit
key like below:
init
job:
id
- Unique identifier to identify this resource within the environmentprefix
- String that will be used as prefix in the name of the resourceimage
- Image name with tag/version. Eg., nginx:1.29
. This is optional. If the image
is not provided, we use the same image that was used to run your original service, which was built with the latest commit in your branch/PR.cmd
- start command. Used on the image
you provide in this config or the image LocalOps built using latest commit in your branch/PR.env
- Pass any environment variable necessary to run this image. In addition, when you don’t provide an image
in this config, the image LocalOps built using latest commit in the PR will be used and all the secrets you added for this service in LocalOps console UI will also be injected into the job.id
or prefix
will swap the resource with a new one in the next deployment. init
is an array. So you can add any number of these jobs. They will be run in the order you have declared here.
dependencies
> exports
variables you declared using below andpreviews.depdendencies
> exports
variables are added too.env
above init job configweb
service won’t start.
ops.json
. LocalOps will provision these resources and ensure they are
active & enabled for your service to use.
ops.json
, write a key called dependencies
and fill up your dependency in the following format.
id
)id
), the resource will be deleted and replaced by any other new one.
prefix
)attachmentsbucket-23490823940
. If you change prefix string, the resource will be deleted and replaced by any
other new one.
exports
)ATTACHMENTS_BUCKET_ARN
and pass ARN of the new S3
bucket to it. So that in your code, you can use it like:
skip_preview
)true
.
preview_only
)true
.
ops.json
when the service is being
deployed.
id
is seen for the first time, it is provisioned.id
is missing, it is deleted automatically during the next service
deployment .ops.json
. For example, you can add
files/objects to the S3 bucket you defined in ops.json
(see above), for example:
ops.json
, LocalOps automatically generates necessary IAM permissions and add them as
policies in the pre-conigured IAM role. Your code can just access the resources defined in ops.json
by name and all
calls made will be authenticated calls by default.
For example, for the S3 bucket defined in ops.json
, LocalOps automatically adds the following necessary IAM
permissions in the pre-configured IAM role.
ops.json
. We plan to grow this list to cover other services in
AWS. Please get in touch with us at help@localops.co if you need anything specific.
previews
, like below:
ops.json
.
In the ops.json
, just define a key called db
under previews
> dependencies
like below and add your database dependencies as an array.
Example:
db
:
id
- Unique identifier to identify this resource within the environmentprefix
- String that will be used as prefix in the name of the resourceengine
- mysql
or postgres
version
- any public version of mysql or postgres available in docker hubexports
- Information of the database resource can be exported to be used within your service. Define a set of key value pairs that will be injected as environment variables in your service. Keys will be injected as such. Values are interpreted as follows.$host
- DNS host of the resource, privately reachable within the cluster. All resources are private.$port
- DNS port of the resource. For eg., you will see $port set as 3306
for MySQL and 5432
for Postgres.$db
- Database name to use from your code to read/write data. LocalOps creates a default database for you when provisioning the database server.$user
- Username to use while authenticating into the database. LocalOps creates a default user for you when provisioning the database server and you can use this variable to get its value injected in your environment variable.$pass
- Password to use while authenticating into the database. LocalOps creates this for you and passes it to you via this var.id
or prefix
will swap the resource with a new one in the next deployment. ops.json
.
In the ops.json
, just define a key called cache
under previews
> dependencies
like below and add your caching dependencies as an array.
Example:
cache
:
id
- Unique identifier to identify this resource within the environmentprefix
- String that will be used as prefix in the name of the resourceengine
- redis
or memcache
version
- any public version of redis or memcache available in docker hubexports
- Information of the caching server can be exported to be used within your service. Define a set of key value pairs that will be injected as environment variables in your service. Keys will be injected as such. Values are interpreted as follows.$host
- DNS host of the resource, privately reachable within the cluster. All resources are private.$port
- DNS port of the resource. For eg., you will see $port set as 6379
for Redis and 11211
for Memcache.id
or prefix
will swap the resource with a new worker in the next deployment. ops.json
.
In the ops.json
, just define a key called queues
under previews
> dependencies
like below and add your dependencies as an array.
Example:
cache
:
id
- Unique identifier to identify this resource within the environmentprefix
- String that will be used as prefix in the name of the resourceengine
- rabbitmq
version
- any public version of rabbitmq available in docker hubexports
- Information of the messaging/queueing server can be exported to be used within your service. Define a set of key value pairs that will be injected as environment variables in your service. Keys will be injected as such. Values are interpreted as follows.$host
- DNS host of the resource, privately reachable within the cluster. All resources are private.$port
- DNS port of the resource. For eg., you will see $port set as 5672
for RabbitMQ.$vhost
- Virtual host of rabbitmq that is created for you to use.$user
- Username to use while authenticating into this server. LocalOps creates a default user for you when provisioning the RabbitMQ server and you can use this variable to get its value injected in your environment variable.$pass
- Password to use while authenticating into this server. LocalOps creates this for you and passes it to you via this variable.id
or prefix
will swap the resource with a new one in the next deployment. ops.json
, just define a key called workers
under previews
like below and add your workers as an array.
Example:
worker
:
id
- Unique identifier to identify this resource within the environmentprefix
- String that will be used as prefix in the name of the resourceimage
- Image name with tag/version. Eg., nginx:1.29
. This is optional. If the image
is not provided, we use the same image that was used to run your original service, which was built with the latest commit in your PR.cmd
- start command. Used on the image
you provide in this config or the image LocalOps built using latest commit in your PR.env
- Pass any environment variable necessary to run this image. In addition, when you don’t provide an image
in this config, the image LocalOps built using latest commit in the PR will be used and all the secrets you added for this service in LocalOps console UI will also be injected into the worker.count
- Number of replicas / containers of the worker to runid
or prefix
will swap the resource with a new one in the next deployment. ops.json
.
cron
key in ops.json
and add any number of scheduled hits by giving
https://<host>/path
.ops.json
example: