Skip to content

Commit

Permalink
Update terraform provider
Browse files Browse the repository at this point in the history
  • Loading branch information
impart-security committed Mar 28, 2024
1 parent a9244bd commit cde1b28
Show file tree
Hide file tree
Showing 44 changed files with 9,431 additions and 82 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [0.4.0] - 2024-03-28

- Add impart_connector Terraform data source
- Add impart_notification_template Terraform resource
- Add impart_monitor Terraform resource

## [0.3.0] - 2024-02-14

### Changed
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.0
0.4.0
33 changes: 33 additions & 0 deletions docs/data-sources/connector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "impart_connector Data Source - impart"
subcategory: ""
description: |-
Manage a connector.
---

# impart_connector (Data Source)

Manage a connector.

## Example Usage

```terraform
# Read in an existing specification
data "impart_connector" "example_connector" {
id = "<id>"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `id` (String) Identifier for this connector.

### Optional

- `connector_type_id` (String) ID of the connector type (eg. ID for our Slack or Jira connector types).
- `is_connected` (Boolean) Whether or not the connector is authenticated via OAuth2.
- `name` (String) Name for this connector.
48 changes: 48 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,54 @@ resource "impart_spec" "example" {
# ignore_changes = all
# }
}
# Create a new notification template
resource "impart_notification_template" "test" {
name = "terraform_notification_template"
connector_id = data.local.example_connector.id
payload = "This is notification template made from terraform"
subject = "Terraform Subject"
destination = ["C060E7NGB61"]
}
#Create a new event monitor
resource "impart_monitor" "test_event" {
name = "terraform_event_monitor"
description = "test event monitor"
notification_template_ids = [impart_notification_template.test.id]
conditions = [
{
threshold = 1,
comparator = "gt",
time_period = 60000,
delay = 0,
details = {
type = "event",
action = "api_access_token_created",
subject_type = "api_access_token_id",
actor_type = "user_id"
}
}
]
}
resource "impart_monitor" "test_metric" {
name = "terraform_event_monitor"
description = "test event monitor"
notification_template_ids = [impart_notification_template.test.id]
conditions = [
{
threshold = 1,
comparator = "lt",
time_period = 60000,
delay = 0,
details = {
type = "metric",
tag = "http-request"
}
}
]
}
```

<!-- schema generated by tfplugindocs -->
Expand Down
1 change: 1 addition & 0 deletions docs/resources/log_binding.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ resource "impart_log_binding" "example" {
%%{HTTPDATE:timestamp} "(?:%%{WORD:http_method}|-) (?:%%{GREEDYDATA:request}|-) (?:HTTP/%%{NUMBER:httpversion}|-( )?)" (?:%%{NUMBER:response_code}|-)
EOF
logstream_id = "logstream_id"
spec_id = resource.impart_spec.example.id
}
```

Expand Down
94 changes: 94 additions & 0 deletions docs/resources/monitor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "impart_monitor Resource - impart"
subcategory: ""
description: |-
Manage a monitor.
---

# impart_monitor (Resource)

Manage a monitor.

## Example Usage

```terraform
# Create a new event monitor
resource "impart_monitor" "test_event" {
name = "terraform_event_monitor"
description = "test event monitor"
notification_template_ids = [impart_notification_template.test.id]
conditions = [
{
threshold = 1,
comparator = "gt",
time_period = 60000,
delay = 0,
details = {
type = "event",
action = "api_access_token_created",
subject_type = "api_access_token_id",
actor_type = "user_id"
}
}
]
}
# Create a new metric monitor
resource "impart_monitor" "test_metric" {
name = "terraform_event_monitor"
description = "test event monitor"
notification_template_ids = [impart_notification_template.test.id]
conditions = [
{
threshold = 1,
comparator = "lt",
time_period = 60000,
delay = 0,
details = {
type = "metric",
tag = "http-request"
}
}
]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `conditions` (Attributes List) An array of conditions for which the monitor will trigger. (see [below for nested schema](#nestedatt--conditions))
- `description` (String) The description for this monitor.
- `name` (String) The name for this monitor.
- `notification_template_ids` (List of String) An array of notification template ids for the templates that will send notifications to their respective connectors.

### Read-Only

- `id` (String) Identifier for this monitor.

<a id="nestedatt--conditions"></a>
### Nested Schema for `conditions`

Required:

- `comparator` (String) Greater than, equal to, or less than (should be one of 'gt', 'lt', or 'eq')
- `delay` (Number) In milliseconds, the offset from now() for the time window.
- `details` (Attributes) (see [below for nested schema](#nestedatt--conditions--details))
- `threshold` (Number) Number of occurrences that need to execute to have this condition be true.
- `time_period` (Number) In milliseconds, the time span from now until when we should be counting events (for example, 60000 is all events in the last minute).

<a id="nestedatt--conditions--details"></a>
### Nested Schema for `conditions.details`

Required:

- `type` (String) The type of monitor (should be one of 'event' or 'metric'

Optional:

- `action` (String) Strictly for event type monitors. A slug of the action the monitor is tracking.
- `actor_type` (String) Strictly for event type monitors. A slug of the actor type the monitor is tracking.
- `subject_type` (String) Strictly for event type monitors. A slug of the subject type the monitor is tracking.
- `tag` (String) Strictly for metric type monitors. The tag the monitor is tracking.
39 changes: 39 additions & 0 deletions docs/resources/notification_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "impart_notification_template Resource - impart"
subcategory: ""
description: |-
Manage an notification template.
---

# impart_notification_template (Resource)

Manage an notification template.

## Example Usage

```terraform
# Create a new notification template
resource "impart_notification_template" "example" {
name = "notification_template_example"
connector_id = resource.impart_connector.example_connector.id
payload = "This is a test message payload"
subject = "Test subject"
destination = ["test-destination-id"]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `connector_id` (String) The connector id.
- `destination` (List of String) An array of destination ids to which the payloads will be sent.
- `name` (String) The name for this notification template.
- `payload` (String) The payload message that will be sent to the Third Party API.
- `subject` (String) The subject message that will be sent to the Third Party API.

### Read-Only

- `id` (String) Identifier for this notification template.
4 changes: 4 additions & 0 deletions examples/data-sources/impart_connector/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Read in an existing specification
data "impart_connector" "example_connector" {
id = "<id>"
}
48 changes: 48 additions & 0 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,51 @@ resource "impart_spec" "example" {
# ignore_changes = all
# }
}

# Create a new notification template
resource "impart_notification_template" "test" {
name = "terraform_notification_template"
connector_id = data.local.example_connector.id
payload = "This is notification template made from terraform"
subject = "Terraform Subject"
destination = ["C060E7NGB61"]
}

#Create a new event monitor
resource "impart_monitor" "test_event" {
name = "terraform_event_monitor"
description = "test event monitor"
notification_template_ids = [impart_notification_template.test.id]
conditions = [
{
threshold = 1,
comparator = "gt",
time_period = 60000,
delay = 0,
details = {
type = "event",
action = "api_access_token_created",
subject_type = "api_access_token_id",
actor_type = "user_id"
}
}
]
}

resource "impart_monitor" "test_metric" {
name = "terraform_event_monitor"
description = "test event monitor"
notification_template_ids = [impart_notification_template.test.id]
conditions = [
{
threshold = 1,
comparator = "lt",
time_period = 60000,
delay = 0,
details = {
type = "metric",
tag = "http-request"
}
}
]
}
1 change: 1 addition & 0 deletions examples/resources/impart_log_binding/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ resource "impart_log_binding" "example" {
%%{HTTPDATE:timestamp} "(?:%%{WORD:http_method}|-) (?:%%{GREEDYDATA:request}|-) (?:HTTP/%%{NUMBER:httpversion}|-( )?)" (?:%%{NUMBER:response_code}|-)
EOF
logstream_id = "logstream_id"
spec_id = resource.impart_spec.example.id
}
39 changes: 39 additions & 0 deletions examples/resources/impart_monitor/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Create a new event monitor
resource "impart_monitor" "test_event" {
name = "terraform_event_monitor"
description = "test event monitor"
notification_template_ids = [impart_notification_template.test.id]
conditions = [
{
threshold = 1,
comparator = "gt",
time_period = 60000,
delay = 0,
details = {
type = "event",
action = "api_access_token_created",
subject_type = "api_access_token_id",
actor_type = "user_id"
}
}
]
}

# Create a new metric monitor
resource "impart_monitor" "test_metric" {
name = "terraform_event_monitor"
description = "test event monitor"
notification_template_ids = [impart_notification_template.test.id]
conditions = [
{
threshold = 1,
comparator = "lt",
time_period = 60000,
delay = 0,
details = {
type = "metric",
tag = "http-request"
}
}
]
}
8 changes: 8 additions & 0 deletions examples/resources/impart_notification_template/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Create a new notification template
resource "impart_notification_template" "example" {
name = "notification_template_example"
connector_id = resource.impart_connector.example_connector.id
payload = "This is a test message payload"
subject = "Test subject"
destination = ["test-destination-id"]
}
Loading

0 comments on commit cde1b28

Please sign in to comment.