Skip to content

Commit

Permalink
feat: add statusflare_status_page resource
Browse files Browse the repository at this point in the history
  • Loading branch information
eidam committed May 18, 2021
1 parent f16eb98 commit a5878f8
Show file tree
Hide file tree
Showing 13 changed files with 539 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ install: build
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}

testacc:
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m -parallel 1
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m -parallel 3 -count=1

clean:
rm -rf ${BINARY}
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ provider "statusflare" {
### Optional

- **account_id** (String) Your Statusflare Account ID. This can also be specified with the `SF_ACCOUNT_ID` env. variable.
- **api_url** (String) Statusflare API URL.
- **api_url** (String) Statusflare API URL. This can also be specified with the `SF_API_URL` env. variable.
- **key_id** (String) Your token's key ID. This can also be specified with the `SF_KEY_ID` env. variable.
- **token** (String) Token's secret part. This can also be specified with the `SF_TOKEN` env. variable.
6 changes: 3 additions & 3 deletions docs/resources/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ resource "statusflare_integration" "example" {

### Required

- **name** (String) The name of the integration
- **secret** (String, Sensitive) The secret of the integration, e.g. webhook URL
- **name** (String) The name of the integration.
- **secret** (String, Sensitive) The secret of the integration, e.g. webhook URL.

### Optional

- **id** (String) The ID of this resource.
- **type** (String) Type of the integration, e.g. webhook
- **type** (String) Type of the integration, e.g. webhook.


8 changes: 4 additions & 4 deletions docs/resources/monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ resource "statusflare_monitor" "example" {

### Required

- **name** (String) The name of the monitor. Must be unique
- **url** (String) URL Address but without schema. It might be www.example.com
- **name** (String) The name of the monitor. Must be unique.
- **url** (String) URL Address but without schema. It might be www.example.com.

### Optional

- **expect_status** (Number) The expected HTTP status code. The default is 200.
- **id** (String) The ID of this resource.
- **integrations** (List of String) IDs of integrations attached to this monitor.
- **method** (String) The HTTP method. The default is 'GET'
- **method** (String) The HTTP method. The default is 'GET'.
- **retries** (Number) Retries or also 'notify_after' field in API. The default is 1.
- **scheme** (String) The scheme might be http or https. The default value is https.
- **worker** (String) Don't know purpose of this field but default value is 'managed'
- **worker** (String) ID of the worker to perform checks from. The default is 'managed'.


60 changes: 60 additions & 0 deletions docs/resources/status_page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "statusflare_status_page Resource - terraform-provider-statusflare"
subcategory: ""
description: |-
---

# statusflare_status_page (Resource)



## Example Usage

```terraform
resource "statusflare_monitor" "example" {
name = "Example monitor"
url = "www.example.com"
}
resource "statusflare_status_page" "example" {
name = "My example status page"
monitors = [statusflare_monitor.example.id]
// following config options are defaults you can override
config = {
title = "Status Page",
logo_url = "statusflare.png",
favicon_url = "favicon.ico",
all_monitors_operational = "All Monitors Operational",
not_all_monitors_operational = "Not All Monitors Operational",
monitor_operational_label = "Operational",
monitor_not_operational_label = "Not Operational",
monitor_no_data_label = "No data",
histogram_no_data = "No data",
histogram_no_incidents = "All good",
histogram_some_incidents = "incident(s)",
}
}
```

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

### Required

- **name** (String) The name of the status page.

### Optional

- **config** (Map of String) Additional configuration of the status page. See example for list of options.
- **custom_domain** (String) The custom domain attached to your status page.
- **custom_domain_path** (String) The path for your custom domain. The default is '/'.
- **hide_monitor_details** (Boolean) Hide monitor details (URL, scheme, ..) on the status page. The default is false.
- **hide_statusflare** (Boolean) Hide statusflare branding/links on the status page. The default is false.
- **histogram_days** (Number) Number of days to render on status page for each monitor. The default is 90.
- **id** (String) The ID of this resource.
- **monitors** (List of String) IDs of monitors attached to this status page.


24 changes: 24 additions & 0 deletions examples/resources/statusflare_status_page/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
resource "statusflare_monitor" "example" {
name = "Example monitor"
url = "www.example.com"
}

resource "statusflare_status_page" "example" {
name = "My example status page"
monitors = [statusflare_monitor.example.id]

// following config options are defaults you can override
config = {
title = "Status Page",
logo_url = "statusflare.png",
favicon_url = "favicon.ico",
all_monitors_operational = "All Monitors Operational",
not_all_monitors_operational = "Not All Monitors Operational",
monitor_operational_label = "Operational",
monitor_not_operational_label = "Not Operational",
monitor_no_data_label = "No data",
histogram_no_data = "No data",
histogram_no_incidents = "All good",
histogram_some_incidents = "incident(s)",
}
}
3 changes: 2 additions & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func New(version string) *schema.Provider {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("SF_API_URL", "https://api.statusflare.com"),
Description: "Statusflare API URL.",
Description: "Statusflare API URL. This can also be specified with the `SF_API_URL` env. variable.",
},
"account_id": {
Type: schema.TypeString,
Expand All @@ -42,6 +42,7 @@ func New(version string) *schema.Provider {
ResourcesMap: map[string]*schema.Resource{
"statusflare_monitor": resourceMonitor(),
"statusflare_integration": resourceIntegration(),
"statusflare_status_page": resourceStatusPage(),
},
DataSourcesMap: map[string]*schema.Resource{
"statusflare_integration": dataSourceIntegration(),
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/resource_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ func resourceIntegration() *schema.Resource {
"name": {
Type: schema.TypeString,
Required: true,
Description: "The name of the integration",
Description: "The name of the integration.",
},
"type": {
Type: schema.TypeString,
Optional: true,
Default: "webhook",
Description: "Type of the integration, e.g. webhook",
Description: "Type of the integration, e.g. webhook.",
},
"secret": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Sensitive: true,
Description: "The secret of the integration, e.g. webhook URL",
Description: "The secret of the integration, e.g. webhook URL.",
},
}

Expand Down
8 changes: 4 additions & 4 deletions internal/provider/resource_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ func resourceMonitor() *schema.Resource {
"name": {
Type: schema.TypeString,
Required: true,
Description: "The name of the monitor. Must be unique",
Description: "The name of the monitor. Must be unique.",
},
"url": {
Type: schema.TypeString,
Required: true,
Description: "URL Address but without schema. It might be www.example.com",
Description: "URL Address but without schema. It might be www.example.com.",
},
"scheme": {
Type: schema.TypeString,
Expand All @@ -31,7 +31,7 @@ func resourceMonitor() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Default: "GET",
Description: "The HTTP method. The default is 'GET'",
Description: "The HTTP method. The default is 'GET'.",
},
"expect_status": {
Type: schema.TypeInt,
Expand All @@ -49,7 +49,7 @@ func resourceMonitor() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Default: "managed",
Description: "Don't know purpose of this field but default value is 'managed'",
Description: "ID of the worker to perform checks from. The default is 'managed'.",
},
"integrations": {
Type: schema.TypeList,
Expand Down
Loading

0 comments on commit a5878f8

Please sign in to comment.