Skip to content

Commit

Permalink
Merge pull request #1 from newrelic/release/v0.0.2
Browse files Browse the repository at this point in the history
Release/v0.0.2
  • Loading branch information
ctrombley committed Mar 10, 2020
2 parents a6d310a + b375101 commit 3ae9f67
Show file tree
Hide file tree
Showing 10 changed files with 233 additions and 64 deletions.
42 changes: 42 additions & 0 deletions .chglog/CHANGELOG.tpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{ if .Versions -}}
<a name="unreleased"></a>
## [Unreleased]

{{ if .Unreleased.CommitGroups -}}
{{ range .Unreleased.CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

{{ range .Versions }}
<a name="{{ .Tag.Name }}"></a>
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}

{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

{{- if .Versions }}
[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
{{ range .Versions -}}
{{ if .Tag.Previous -}}
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
{{ end -}}
{{ end -}}
{{ end -}}
10 changes: 10 additions & 0 deletions .chglog/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/newrelic/terraform-newrelic-apm
options:
header:
pattern: "^(.*)$"
pattern_maps:
- Subject
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.26.0
hooks:
- id: terraform_fmt
- id: terraform_docs
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: check-merge-conflict
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<a name="unreleased"></a>
## [Unreleased]


<a name="v0.0.2"></a>
## [v0.0.2] - 2020-03-10

<a name="v0.0.1"></a>
## v0.0.1 - 2020-03-10

[Unreleased]: https://github.com/newrelic/terraform-newrelic-apm/compare/v0.0.2...HEAD
[v0.0.2]: https://github.com/newrelic/terraform-newrelic-apm/compare/v0.0.1...v0.0.2
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#############################
# Global vars
#############################
PROJECT_NAME := $(shell basename $(shell pwd))

RELEASE_SCRIPT ?= ./scripts/release.sh

release:
@echo "=== $(PROJECT_NAME) === [ release ]: Generating release."
$(RELEASE_SCRIPT) $(version)

.PHONY: release
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,53 @@ module "dummy-app-monitor" {
1. This module does not create a notification channel. Use the [newrelic_alert_channel](https://www.terraform.io/docs/providers/newrelic/r/alert_channel.html) resource for this.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Providers

| Name | Version |
|------|---------|
| newrelic | ~> 1.9.0 |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:-----:|
| account\_id | The account ID the application reports to | `number` | n/a | yes |
| apdex\_critical\_threshold | The threshold below which a critical violation will be triggered for the Apdex condition (percentage satisfied users) | `number` | `0.7` | no |
| apdex\_duration | The evaluation window length of the Apdex condition (minutes) | `number` | `5` | no |
| apdex\_t | The response time above which a transaction is considered tolerable | `number` | `0.4` | no |
| apdex\_warning\_threshold | The threshold below which a warning violation will be triggered for the Apdex condition (percentage satisfied users) | `number` | `0.8` | no |
| application\_name | The name of the New Relic application to monitor | `string` | n/a | yes |
| application\_url | The URL to use when configuring a Synthetics monitor for this application | `string` | n/a | yes |
| channel\_ids | The notification channel IDs to link to this alert policy | `list(number)` | n/a | yes |
| error\_rate\_critical\_threshold | The threshold above which a critical violation will be triggered for the error rate condition (errors/minute) | `number` | `5` | no |
| error\_rate\_duration | The evaluation window length of the error rate condition (minutes) | `number` | `5` | no |
| error\_rate\_warning\_threshold | The threshold above which a warning violation will be triggered for the error rate condition (errors/minute) | `number` | `2` | no |
| incident\_preference | The rollup strategy of the alert policy. Valid values are PER\_POLICY, PER\_CONDITION, and PER\_CONDITION\_AND\_TARGET | `string` | `"PER_POLICY"` | no |
| policy\_name | The name of the alert policy to manage | `string` | n/a | yes |
| response\_time\_critical\_threshold | The threshold above which a critical violation will be triggered for the response time condition (seconds) | `number` | n/a | yes |
| response\_time\_duration | The evaluation window length of the error rate condition (minutes) | `number` | `5` | no |
| response\_time\_warning\_threshold | The threshold above which a warning violation will be triggered for the response time condition (seconds) | `number` | `1` | no |
| runbook\_url | A URL that points to a runbook for when this application is failing | `string` | n/a | yes |
| synthetics\_condition\_duration | The evaluation window length of the Synthetics condition (minutes) | `number` | `5` | no |
| synthetics\_condition\_threshold | The threshold above which a critical violation will be triggered for the Synthetics condition (failure count) | `number` | `0` | no |
| synthetics\_monitor\_frequency | The interval on which to run Synthetics checks against the provided application URL | `number` | `5` | no |
| synthetics\_monitor\_locations | The locations to run Synthetics checks from | `list(string)` | <pre>[<br> "AWS_US_EAST_1"<br>]</pre> | no |
| synthetics\_monitor\_validation\_string | An optional string to check existence of when running Synthetics checks | `string` | n/a | yes |
| synthetics\_monitor\_verify\_ssl | If true, verifies SSL when running Synthetics checks | `bool` | `false` | no |

## Outputs

| Name | Description |
|------|-------------|
| apdex\_condition\_id | n/a |
| error\_rate\_condition\_id | n/a |
| policy\_id | n/a |
| reponse\_time\_condition\_id | n/a |
| synthetics\_condition\_id | n/a |
| synthetics\_monitor\_id | n/a |

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

## License

MIT Licensed. See LICENSE for full details.
Apache 2.0 Licensed. See LICENSE for full details.
18 changes: 9 additions & 9 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
locals {
policy_name = var.policy_name == null ? "${var.application_name}: APM Monitoring" : var.policy_name
policy_name = var.policy_name == null ? "${var.application_name}: APM Monitoring" : var.policy_name
}

resource "newrelic_alert_policy" "policy" {
name = local.policy_name
name = local.policy_name
incident_preference = var.incident_preference
channel_ids = var.channel_ids
channel_ids = var.channel_ids
}

resource "newrelic_nrql_alert_condition" "apdex_condition" {
Expand Down Expand Up @@ -75,15 +75,15 @@ resource "newrelic_nrql_alert_condition" "error_rate_condition" {
resource "newrelic_synthetics_monitor" "synthetics_monitor" {
count = var.application_url == null ? 0 : 1

name = "${var.application_name}: SIMPLE"
type = "SIMPLE"
name = "${var.application_name}: SIMPLE"
type = "SIMPLE"
frequency = var.synthetics_monitor_frequency
status = "ENABLED"
status = "ENABLED"
locations = var.synthetics_monitor_locations

uri = var.application_url
validation_string = var.synthetics_monitor_validation_string
verify_ssl = var.synthetics_monitor_verify_ssl
uri = var.application_url
validation_string = var.synthetics_monitor_validation_string
verify_ssl = var.synthetics_monitor_verify_ssl
}


Expand Down
12 changes: 6 additions & 6 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
output "policy_id" {
value = newrelic_alert_policy.policy.id
value = newrelic_alert_policy.policy.id
}

output "apdex_condition_id" {
value = newrelic_nrql_alert_condition.apdex_condition.id
value = newrelic_nrql_alert_condition.apdex_condition.id
}

output "error_rate_condition_id" {
value = newrelic_nrql_alert_condition.error_rate_condition.id
value = newrelic_nrql_alert_condition.error_rate_condition.id
}

output "synthetics_monitor_id" {
value = length(newrelic_synthetics_monitor.synthetics_monitor) > 0 ? newrelic_synthetics_monitor.synthetics_monitor[0].id : null
value = length(newrelic_synthetics_monitor.synthetics_monitor) > 0 ? newrelic_synthetics_monitor.synthetics_monitor[0].id : null
}

output "synthetics_condition_id" {
value = length(newrelic_nrql_alert_condition.synthetics_condition) > 0 ? newrelic_nrql_alert_condition.synthetics_condition[0].id : null
value = length(newrelic_nrql_alert_condition.synthetics_condition) > 0 ? newrelic_nrql_alert_condition.synthetics_condition[0].id : null
}

output "reponse_time_condition_id" {
value = length(newrelic_nrql_alert_condition.response_time_condition) > 0 ? newrelic_nrql_alert_condition.response_time_condition[0].id : null
value = length(newrelic_nrql_alert_condition.response_time_condition) > 0 ? newrelic_nrql_alert_condition.response_time_condition[0].id : null
}
38 changes: 38 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

COLOR_RED='\033[0;31m'
COLOR_NONE='\033[0m'
CURRENT_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)

if [ $CURRENT_GIT_BRANCH != 'master' ]; then
printf "\n"
printf "${COLOR_RED} Error: The release.sh script must be run while on the master branch. \n ${COLOR_NONE}"
printf "\n"

exit 1
fi

if [ $# -ne 1 ]; then
printf "\n"
printf "${COLOR_RED} Error: Release version argument required. \n\n ${COLOR_NONE}"
printf " Example: \n\n ./tools/release.sh 0.9.0 \n\n"
printf " Example (make): \n\n make release version=0.9.0 \n"
printf "\n"

exit 1
fi

RELEASE_VERSION=$1
GIT_USER=$(git config user.email)

echo "Generating release for v${RELEASE_VERSION} using system user git user ${GIT_USER}"

git checkout -b release/v${RELEASE_VERSION}

# Auto-generate CHANGELOG updates
git-chglog --next-tag v${RELEASE_VERSION} -o CHANGELOG.md

# Commit CHANGELOG updates
git add CHANGELOG.md internal/version/version.go
git commit -m "chore(changelog): Update CHANGELOG for v${RELEASE_VERSION}"
git push origin release/v${RELEASE_VERSION}
Loading

0 comments on commit 3ae9f67

Please sign in to comment.