make init
make build
Do not edit files under docs
, they are generated from templates
and the source code.
To preview how the docs will look in the terraform registry, paste them here https://registry.terraform.io/tools/doc-preview
Important: Run this command before commiting changes to git, to update the docs for recent changes.
make docs
First, build and install the provider.
make install
Then, run the following command to initialize the workspace and apply the sample configuration.
terraform init && terraform apply
For local binary, configure terraform as:
terraform {
required_providers {
satori = {
version = "~>1.0.0"
source = "satoricyber.com/terraform/satori"
}
}
}
In-order to have up to date resource state and configuration file on resources that were not managed by terraform, the client will be required to define which resources he would like to manage by terraform and import them along with updating the Terraform’s state.
This document will instruct the user how to conduct this procedure.
These instructions will have 3 main parts:
Generating a new main.tf
file that will include all of the desired imported resources’ configuration.
Applying the import command in-order to sync the terraform’s state.
Setting up the files names to work against the new generated configuration file.
Terraform version 1.5.x+ is required, as this feature is not supported on older versions.
Note: If you want, you can define a satori_imports
module and use it to import the resources. This will allow you to keep the main.tf file clean and organized, and would require you to execute in step 3 only option 1. So it will save some work & leave the imports module as it was for future reference.
-
Create a new
main.tf
with the Satori provider information. More info can be found here https://registry.terraform.io/providers/SatoriCyber/satori/latest.Initialize the terraform directory with the following command:
terraform init
-
For each resource you want to manage using terraform add the terraform import resource:
import { to = ${terraform_resource_type}.${terraform_resource_unique_name_per_type} id = "${satori_resource_id}" }
For example:
import { to = satori_dataset.my_imported_dataset id = "fvf9e3a7-5bcd-4b7f-9230-3e5f5wce0b85" }
In the above example, we would like to import a
satori_dataset
resource type, and its terraform resource name will bemy_imported_dataset
. To this resource we would like to import a satori dataset resource which has the IDfvf9e3a7-5bcd-4b7f-9230-3e5f5wce0b85
. -
Once you’ve configured for each resource that you want to import the proper terraform import resource which has the proper details. Run the following command:
terraform plan -generate-config-out=new_main.tf
The command above will create under the working directory a new file,
new_main.tf
that will contain all the resources’ configurations of theimport resource
you’ve defined above.
Now after creating the terraform configuration file, we would like to synchronize the terraform’s state. In-order to do so, run the following command:
terraform apply
The command above will update the terraform state to match the configuration file generated by the previous command. (As long that no changes occurred on the imported resource between the generation of the configuration file and the above command)
This part has 2 options available for it:
- From the
main.tf
file remove all of the terraform import resources you’ve generated in step 2 of Part 1. - From the
new_main.tf
copy the entire content and paste it into the end ofmain.tf
file.
-
From
main.tf
copy all the details for the provider to thenew_main.tf
: For example:terraform { required_providers { satori = { source = "Satoricyber/satori" version = "version-your-using" } } } provider "satori" { service_account = "service-account-id" service_account_key = "service-account-key" satori_account = "satori-account-id" }
-
Change the name of the current
main.tf
file toimports_main.tf
(or any other name that is notmain.tf
) -
Change the name of
new_main.tf
tomain.tf
Now, when running the terraform plan
command, you should see the imported resources’ configuration file and the state should be in sync.
terraform plan
meaning that the configuration file, the state, and the resources in our system are in sync.
From this point forward you are able to manage those resources using the terraform command
Happy terraforming… 😀