Skip to content

Commit

Permalink
U-1166 Make sure terraform applies nicely (avoid updating unspecified…
Browse files Browse the repository at this point in the history
… fields) (#96)
  • Loading branch information
PetrHeinz committed Jun 14, 2024
1 parent 48b5f4b commit a4bf877
Show file tree
Hide file tree
Showing 39 changed files with 328 additions and 86 deletions.
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ GOLANGCI_LINT := golangci-lint run --disable-all \
-E gosimple \
-E govet \
-E ineffassign \
-E maligned \
-E staticcheck \
-E typecheck \
-E unused
VERSION := 0.9.2
VERSION := 0.10.0
.PHONY: test build

help:
Expand Down Expand Up @@ -63,7 +62,6 @@ fmt: lint-init
terraform fmt -recursive

gen:
terraform fmt -check -diff -recursive
go generate ./...
@echo
@echo "docs/ can be previewed at https://registry.terraform.io/tools/doc-preview"
Expand Down
3 changes: 0 additions & 3 deletions docs/data-sources/betteruptime_monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ Monitor lookup.
`v1` Proxy-based infrastructure. We use proxies around the world to make regional checks.

`v2` Edge-based infrastructure. More advanced infrastructure, allows running low level checks in regions.

When not set, we use proxy-based infrastructure.
- **confirmation_period** (Number) How long should we wait after observing a failure before we start a new incident? In seconds.
- **created_at** (String) The time when this monitor was created.
- **domain_expiration** (Number) How many days before the domain expires do you want to be alerted? Valid values are 1, 2, 3, 7, 14, 30, and 60.
Expand All @@ -46,7 +44,6 @@ Monitor lookup.

`ipv6` Use IPv6 only

When not set, we use both IPv4 and IPv6 for our checks.
Note: ip_version is used only if "checks_version" is set to "v2".
- **last_checked_at** (String) When the website was last checked.
- **maintenance_days** (List of String) An array of maintenance days to set. If a maintenance window is overnight both affected days should be set. Allowed values are ["mon", "tue", "wed", "thu", "fri", "sat", "sun"] or any subset of these days.
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/betteruptime_aws_cloudwatch_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ https://betterstack.com/docs/uptime/api/aws-cloudwatch-integrations/

- **call** (Boolean) Do we call the on-call person?
- **email** (Boolean) Do we send an email to the on-call person?
- **id** (String) The ID of the AWS CloudWatch Integration.
- **name** (String) The name of the AWS CloudWatch Integration.
- **paused** (Boolean) Is the AWS CloudWatch integration paused.
- **policy_id** (Number) ID of the escalation policy associated with the AWS CloudWatch integration.
Expand All @@ -31,6 +30,7 @@ https://betterstack.com/docs/uptime/api/aws-cloudwatch-integrations/

### Read-Only

- **id** (String) The ID of the AWS CloudWatch Integration.
- **webhook_url** (String) The webhook URL for the AWS CloudWatch integration.


2 changes: 1 addition & 1 deletion docs/resources/betteruptime_azure_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ https://betterstack.com/docs/uptime/api/azure-integrations/

- **call** (Boolean) Do we call the on-call person?
- **email** (Boolean) Do we send an email to the on-call person?
- **id** (String) The ID of the Azure Integration.
- **name** (String) The name of the Azure Integration.
- **paused** (Boolean) Is the Azure integration paused.
- **policy_id** (Number) ID of the escalation policy associated with the Azure integration.
Expand All @@ -31,6 +30,7 @@ https://betterstack.com/docs/uptime/api/azure-integrations/

### Read-Only

- **id** (String) The ID of the Azure Integration.
- **webhook_url** (String) The webhook URL for the Azure integration.


2 changes: 1 addition & 1 deletion docs/resources/betteruptime_datadog_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ https://betterstack.com/docs/uptime/api/datadog-integrations/
- **alerting_rule** (String) Should we alert only on alarms, or on both alarms and warnings. Possible values: alert, alert_and_warn.
- **call** (Boolean) Do we call the on-call person?
- **email** (Boolean) Do we send an email to the on-call person?
- **id** (String) The ID of the Datadog Integration.
- **name** (String) The name of the Datadog Integration.
- **paused** (Boolean) Is the Datadog integration paused.
- **policy_id** (Number) ID of the escalation policy associated with the Datadog integration.
Expand All @@ -32,6 +31,7 @@ https://betterstack.com/docs/uptime/api/datadog-integrations/

### Read-Only

- **id** (String) The ID of the Datadog Integration.
- **webhook_url** (String) The webhook URL for the Datadog integration.


Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ https://betterstack.com/docs/uptime/api/google-monitoring-integrations/

- **call** (Boolean) Do we call the on-call person?
- **email** (Boolean) Do we send an email to the on-call person?
- **id** (String) The ID of the Google Monitoring Integration.
- **name** (String) The name of the Google Monitoring Integration.
- **paused** (Boolean) Is the Google Monitoring integration paused.
- **policy_id** (Number) ID of the escalation policy associated with the Google Monitoring integration.
Expand All @@ -31,6 +30,7 @@ https://betterstack.com/docs/uptime/api/google-monitoring-integrations/

### Read-Only

- **id** (String) The ID of the Google Monitoring Integration.
- **webhook_url** (String) The webhook URL for the Google Monitoring integration.


2 changes: 1 addition & 1 deletion docs/resources/betteruptime_grafana_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ https://betterstack.com/docs/uptime/api/grafana-integrations/

- **call** (Boolean) Do we call the on-call person?
- **email** (Boolean) Do we send an email to the on-call person?
- **id** (String) The ID of the Grafana Integration.
- **name** (String) The name of the Grafana Integration.
- **paused** (Boolean) Is the Grafana integration paused.
- **policy_id** (Number) ID of the escalation policy associated with the Grafana integration.
Expand All @@ -31,6 +30,7 @@ https://betterstack.com/docs/uptime/api/grafana-integrations/

### Read-Only

- **id** (String) The ID of the Grafana Integration.
- **webhook_url** (String) The webhook URL for the Grafana integration.


3 changes: 0 additions & 3 deletions docs/resources/betteruptime_monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ https://betterstack.com/docs/uptime/api/monitors/
`v1` Proxy-based infrastructure. We use proxies around the world to make regional checks.

`v2` Edge-based infrastructure. More advanced infrastructure, allows running low level checks in regions.

When not set, we use proxy-based infrastructure.
- **confirmation_period** (Number) How long should we wait after observing a failure before we start a new incident? In seconds.
- **domain_expiration** (Number) How many days before the domain expires do you want to be alerted? Valid values are 1, 2, 3, 7, 14, 30, and 60.
- **email** (Boolean) Should we send an email to the on-call person?
Expand All @@ -72,7 +70,6 @@ https://betterstack.com/docs/uptime/api/monitors/

`ipv6` Use IPv6 only

When not set, we use both IPv4 and IPv6 for our checks.
Note: ip_version is used only if "checks_version" is set to "v2".
- **maintenance_days** (List of String) An array of maintenance days to set. If a maintenance window is overnight both affected days should be set. Allowed values are ["mon", "tue", "wed", "thu", "fri", "sat", "sun"] or any subset of these days.
- **maintenance_from** (String) Start of the maintenance window each day. We won't check your website during this window. Example: "01:00:00"
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/betteruptime_monitor_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ https://betterstack.com/docs/uptime/api/monitor-groups/
### Read-Only

- **created_at** (String) The time when this monitor group was created.
- **id** (String) The ID of this Monitor.
- **id** (String) The ID of this Monitor group.
- **updated_at** (String) The time when this monitor group was updated.


2 changes: 1 addition & 1 deletion docs/resources/betteruptime_new_relic_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ https://betterstack.com/docs/uptime/api/new-relic-integrations/
- **alerting_rule** (String) Should we alert only on alarms, or on both alarms and warnings. Possible values: alert, alert_and_warn.
- **call** (Boolean) Do we call the on-call person?
- **email** (Boolean) Do we send an email to the on-call person?
- **id** (String) The ID of the AWS CloudWatch Integration.
- **name** (String) The name of the AWS CloudWatch Integration.
- **paused** (Boolean) Is the AWS CloudWatch integration paused.
- **policy_id** (Number) ID of the escalation policy associated with the AWS CloudWatch integration.
Expand All @@ -32,6 +31,7 @@ https://betterstack.com/docs/uptime/api/new-relic-integrations/

### Read-Only

- **id** (String) The ID of the AWS CloudWatch Integration.
- **webhook_url** (String) The webhook URL for the AWS CloudWatch integration.


4 changes: 2 additions & 2 deletions docs/resources/betteruptime_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Required:

Optional:

- **id** (Number) The ID of the resource to notify during an incident. Required for user, webhook, slack_integration, microsoft_teams_integration and zapier_webhook member types. This is e.g. the ID of the user to notify when member type is user.
- **team_id** (Number, Deprecated) The ID of the team to notify when member team is entire_team. When left empty, the default team for the incident is used.
- **id** (Number) The ID of the resource to notify during an incident. Required for user, webhook, slack_integration, microsoft_teams_integration and zapier_webhook member types. This is e.g. the ID of the user to notify when member type is user, or team ID of when member type is current_on_call.
- **team_id** (Number, Deprecated) The ID of the team to notify when member team is entire_team. When left empty, the default team for the incident is used. This field is deprecated, use id instead.


2 changes: 1 addition & 1 deletion docs/resources/betteruptime_prometheus_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ https://betterstack.com/docs/uptime/api/prometheus-integrations/

- **call** (Boolean) Do we call the on-call person?
- **email** (Boolean) Do we send an email to the on-call person?
- **id** (String) The ID of the AWS CloudWatch Integration.
- **name** (String) The name of the AWS CloudWatch Integration.
- **paused** (Boolean) Is the AWS CloudWatch integration paused.
- **policy_id** (Number) ID of the escalation policy associated with the AWS CloudWatch integration.
Expand All @@ -31,6 +30,7 @@ https://betterstack.com/docs/uptime/api/prometheus-integrations/

### Read-Only

- **id** (String) The ID of the AWS CloudWatch Integration.
- **webhook_url** (String) The webhook URL for the AWS CloudWatch integration.


4 changes: 2 additions & 2 deletions docs/resources/betteruptime_status_page_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ https://betterstack.com/docs/uptime/api/status-page-resources/
### Optional

- **explanation** (String) A detailed text displayed as a help icon.
- **history** (Boolean) (Deprecated) Do you want to show the 90-day incident history for this item?
- **history** (Boolean, Deprecated) Do you want to display detailed historical status for this item? This field is deprecated, use widget_type instead.
- **position** (Number) The position of this resource on your status page, indexed from zero. If you don't specify a position, we add the resource to the end of the status page. When you specify a position of an existing resource, we add the resource to this position and shift resources below to accommodate.
- **status_page_section_id** (Number) The ID of the Status Page Section. If you don't specify a status_page_section_id, we add the resource to the first section. If there are no sections in the status page yet, one will be automatically created for you.
- **widget_type** (String) What widget to display for this resource. Expects one of three values: plain - only display status, history - display detailed historical status, response_times - add a response times chart (only for Monitor resource type. This takes preference over history when both parameters are present.
- **widget_type** (String) What widget to display for this resource. Expects one of three values: plain - only display status, history - display detailed historical status, response_times - add a response times chart (only for Monitor resource type). This takes preference over history when both parameters are present.

### Read-Only

Expand Down
1 change: 1 addition & 0 deletions internal/provider/data_incoming_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func newIncomingWebhookDataSource() *schema.Resource {
case "name":
cp.Required = true
cp.Optional = false
cp.Computed = false
default:
cp.Computed = true
cp.Optional = false
Expand Down
12 changes: 12 additions & 0 deletions internal/provider/integration_schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,49 @@ var integrationFieldSchema = map[string]*schema.Schema{
Description: "The name of the field.",
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"special_type": {
Description: "A special type of the field. Can be alert_id or cause or otherwise null for a custom field.",
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"field_target": {
Description: "The target of the field. Can be any of the following: from_email, subject, or body for email integrations or query_string, header, body, json and xml for incoming webhooks.",
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"target_field": {
Description: "The target field within the content of the field_target. Should be a JSON key when field_target is json, a CSS selector when field_target is XML, name of the header for headers or a parameter name for query parameters",
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"match_type": {
Description: "The match type of the field. Can be any of the following: match_before, match_after, match_between, match_regex, or match_everything.",
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"content": {
Description: "How should we extract content the field. Should be a valid Regex when match_type is match_regex.",
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"content_before": {
Description: "When should we stop extracting content for the field. Should be present when match_type is either match_between or match_before.",
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"content_after": {
Description: "When should we start extracting content for the field. Should be present when match_type is either match_between or match_after.",
Type: schema.TypeString,
Optional: true,
Computed: true,
},
}

Expand All @@ -53,21 +61,25 @@ var integrationRuleSchema = map[string]*schema.Schema{
Description: "The target of the rule. Can be any of the following: from_email, subject, or body for email integrations or query_string, header, body, json and xml for incoming webhooks.",
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"target_field": {
Description: "The target field within the content of the rule_target. Should be a JSON key when rule_target is json, a CSS selector when rule_target is XML, name of the header for headers or a parameter name for query parameters",
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"match_type": {
Description: "The type of the rule. Can be any of the following: contains, contains_not, matches_regex, matches_regex_not, equals, or equals_not.",
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"content": {
Description: "The content we should match to satisfy the rule. Should be a valid Regex when match_type is match_regex.",
Type: schema.TypeString,
Optional: true,
Computed: true,
},
}

Expand Down
16 changes: 12 additions & 4 deletions internal/provider/resource_aws_cloudwatch_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,67 +15,75 @@ var awsCloudWatchIntegrationSchema = map[string]*schema.Schema{
Description: "Used to specify the team the resource should be created in when using global tokens.",
Type: schema.TypeString,
Optional: true,
Default: nil,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return d.Id() != ""
},
},
"id": {
Description: "The ID of the AWS CloudWatch Integration.",
Type: schema.TypeString,
Optional: false,
Computed: true,
Optional: true,
},
"name": {
Description: "The name of the AWS CloudWatch Integration.",
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"policy_id": {
Description: "ID of the escalation policy associated with the AWS CloudWatch integration.",
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"call": {
Description: "Do we call the on-call person?",
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"sms": {
Description: "Do we send an SMS to the on-call person?",
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"email": {
Description: "Do we send an email to the on-call person?",
Type: schema.TypeBool,
Optional: true,
Default: true,
Computed: true,
},
"push": {
Description: "Do we send a push notification to the on-call person?",
Type: schema.TypeBool,
Optional: true,
Default: true,
Computed: true,
},
"team_wait": {
Description: "How long we wait before escalating the incident alert to the team. In seconds.",
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"recovery_period": {
Description: "How long the alert must be up to automatically mark an incident as resolved. In seconds.",
Type: schema.TypeInt,
Optional: true,
Default: 0,
Computed: true,
},
"paused": {
Description: "Is the AWS CloudWatch integration paused.",
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"webhook_url": {
Description: "The webhook URL for the AWS CloudWatch integration.",
Type: schema.TypeString,
Optional: false,
Computed: true,
},
}
Expand Down
Loading

0 comments on commit a4bf877

Please sign in to comment.