micole / terraform-provider-sigsci

Signal sciences terraform provider

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sigsci Terraform Provider

🚨 NOTICE 🚨

Effective May 17th 2021 the default branch will change from master to main. Run the following commands to update a local clone:

git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a

Requirements

Check out the Terraform Documentation and their Introduction for more information on terraform

Building the provider

If you are using terraform >0.13.x, our release can be automatically downloaded from their registry using the block described in "Using the provider"

If you are using terraform 0.12.x, you must either build or copy the appropriate executable to your plugin directory. ex terraform.d/plugins/darwin_amd64

You may find prebuilt binaries in our Releases.

If you wish to build from source, first make the correct directory, cd to it, and checkout the repo. Running make build will then build the provider and output it to terraform-provider-sigsci

mkdir -p $GOPATH/src/github.com/signalsciences/
cd $GOPATH/src/github.com/signalsciences/
git clone git@github.com:signalsciences/terraform-provider-sigsci.git
cd terraform-provider-sigsci
make build
cp terraform-provider-sigsci ~/.terraform.d/plugins

Using the provider

You must provide corp, email, and either form of authentication. This can be added in the provider block or with environment variables (recommended).

# Terraform 0.13.x
terraform {
  required_providers {
    sigsci = {
      source = "signalsciences/sigsci"
    }
  }
}

# Required configuration block (for all versions of terraform)
provider "sigsci" {
  //  corp = ""       // Required. may also provide via env variable SIGSCI_CORP
  //  email = ""      // Required. may also provide via env variable SIGSCI_EMAIL
  //  auth_token = "" //may also provide via env variable SIGSCI_TOKEN
  //  password = ""   //may also provide via env variable SIGSCI_PASSWORD
}

Corp resources

Site

Lists

Tags

Rules

Integrations

Site resources

Lists

Rules

Tags

Redactions

Alerts

Templated Rules

Allowlist

Blocklist

Header Links

Integrations

More information on each resource and field can be found on the Signal Sciences Api Docs.

Importing

All resources are importable. Importing will vary depending on if you are importing a corp level resource, or a site level resource

Corp Resources
terraform import resource.name id // General form
terraform import sigsci_site.my-site test_site // Example
Site Resources
terraform import resource.name site_short_name:id //General form
terraform import sigsci_site_list.manual-list test_site:site.manual-list //Example

Example

main.tf has an example of every resource

resource "sigsci_site" "my-site" {
  short_name             = "manual_test"
  display_name           = "manual terraform test"
  block_duration_seconds = 86400
  block_http_code        = 406
  agent_anon_mode        = ""
  agent_level            = "block"
}

resource "sigsci_site_signal_tag" "test_tag" {
  site_short_name = sigsci_site.my-site.short_name
  name            = "My new signal tag"
  description     = "description"
}

resource "sigsci_site_alert" "test_site_alert" {
  site_short_name = sigsci_site.my-site.short_name
  tag_name        = sigsci_site_signal_tag.test_tag.id
  long_name       = "test_alert"
  interval        = 10
  threshold       = 12
  enabled         = true
  action          = "info"
}

resource "sigsci_site_rule" "test" {
  site_short_name = sigsci_site.my-site.short_name
  type            = "signal"
  group_operator  = "any"
  enabled         = true
  reason          = "Example site rule update"
  signal          = "SQLI"
  expiration      = ""

  conditions {
    type     = "single"
    field    = "ip"
    operator = "equals"
    value    = "1.2.3.4"
  }
  conditions {
    type     = "single"
    field    = "ip"
    operator = "equals"
    value    = "1.2.3.5"
    conditions {
      type           = "multival"
      field          = "ip"
      operator       = "equals"
      group_operator = "all"
      value          = "1.2.3.8"
    }
  }

  actions {
    type = "excludeSignal"
  }
}

resource "sigsci_corp_list" "test_list" {
  name        = "My corp list"
  type        = "ip"
  description = "Some IPs"
  entries = [
    "4.5.6.7",
    "2.3.4.5",
    "1.2.3.4",
  ]
}

About

Signal sciences terraform provider

License:MIT License


Languages

Language:Go 95.4%Language:HCL 4.5%Language:Makefile 0.2%