- Terraform 1.5.7
- Go 1.22.2
Clone the repo
git clone https://github.com/Traceableai/traceable-terraform-provider.git
cd traceable-terraform-provider
Install packages and build
go mod tidy
go build -o terraform-provider-example
provider "example" {
platform_url=""
api_token=""
}
platform_url
: The platform url to be usedapi_token
: API token for accessing the platform
resource "example_ip_range_rule" "my_ip_range" {
name = "first_rule_2"
rule_action = "RULE_ACTION_ALERT"
event_severity = "LOW"
raw_ip_range_data = [
"1.1.1.1",
"3.3.3.3"
]
environment=[]
description="rule created from custom provider"
}
name
: (string) name of the rulerule_action
: (string) type of action of the rule to be created [RULE_ACTION_BLOCK, RULE_ACTION_ALERT, RULE_ACTION_ALLOW]event_severity
: (string) severity of the rule [LOW, MEDIUM, HIGH]raw_ip_range_data
: (set of string) list of the ip addresses(IPv4 or IPv6), cidr ranges that the rule would apply onenvironment
: (set of string) list of the env for which the rule would be applicable
expiration
: (string) expiration time of the rule (this attribute don't apply onRULE_ACTION_ALERT
, don't pass this attribute if we need to block or allow indefinetly)description
: (string) description of the rule
Inside ~/.terraform.d
directory
Create a new directory path for a custom Terraform provider, where Terraform will look for local provider plugins.
mkdir -p plugins/terraform.local/local/example/0.0.1/darwin_amd64/
Move provider binary terraform-provider-example
to this directory plugins/terraform.local/local/example/0.0.1/darwin_amd64/
Add provider binary path to your .terraformrc
(if not exist create and paste below lines) to run it locally
provider_installation {
filesystem_mirror {
path = "/Users/<USER>/.terraform.d/plugins"
}
direct {
exclude = ["terraform.local/*/*"]
}
}
Initialize a Terraform working directory and Apply the changes.
terraform init
terraform apply