Prerequisites
- Sign up for a free Axiom account. All you need is an email address.
- Create an advanced API token in Axiom with the permissions to perform the actions you want to use Terraform for. For example, to use Terraform to create and update datasets, create the advanced API token with these permissions.
- Create a Terraform account.
- Install the Terraform CLI.
Install the provider
To install the Axiom Terraform Provider from the Terraform Registry, follow these steps:-
Add the following code to your Terraform configuration file. Replace
API_TOKEN
with the Axiom API token you have generated. For added security, store the API token in an environment variable. -
In your terminal, go to the folder of your main Terraform configuration file, and then run the command
terraform init
.
Create new resources
Create dataset
To create a dataset in Axiom using the provider, add the following code to your Terraform configuration file. Customize thename
and description
fields.
Create notifier
To create a Slack notifier in Axiom using the provider, add the following code to your Terraform configuration file. ReplaceSLACK_URL
with the webhook URL from your Slack instance. For more information on obtaining this URL, see the Slack documentation.
- Replace
DISCORD_CHANNEL
with the webhook URL from your Discord instance. For more information on obtaining this URL, see the Discord documentation. - Replace
DISCORD_TOKEN
with your Discord API token. For more information on obtaining this token, see the Discord documentation.
EMAIL1
and EMAIL2
with the email addresses you want to notify.
Create monitor
To create a monitor in Axiom using the provider, add the following code to your Terraform configuration file and customize it:test_dataset
and the notifier test_slack_notifier
. These are resources you have created and accessed in the sections above.
- Customize the
name
and thedescription
fields. - In the
apl_query
field, specify the APL query for the monitor.
Create user
To create a user in Axiom using the provider, add the following code to your Terraform configuration file. Customize thename
, email
, and role
fields.
Access existing resources
Access existing dataset
To access an existing dataset, follow these steps:-
Determine the ID of the Axiom dataset by sending a GET request to the
datasets
endpoint of the Axiom API. -
Add the following code to your Terraform configuration file. Replace
DATASET_ID
with the ID of the Axiom dataset.
Access existing notifier
To access an existing notifier, follow these steps:-
Determine the ID of the Axiom notifier by sending a GET request to the
notifiers
endpoint of the Axiom API. -
Add the following code to your Terraform configuration file. Replace
NOTIFIER_ID
with the ID of the Axiom notifier.
Access existing monitor
To access an existing monitor, follow these steps:-
Determine the ID of the Axiom monitor by sending a GET request to the
monitors
endpoint of the Axiom API. -
Add the following code to your Terraform configuration file. Replace
MONITOR_ID
with the ID of the Axiom monitor.
Access existing user
To access an existing user, follow these steps:-
Determine the ID of the Axiom user by sending a GET request to the
users
endpoint of the Axiom API. -
Add the following code to your Terraform configuration file. Replace
USER_ID
with the ID of the Axiom user.