Skip to content

Commit e1075a6

Browse files
authored
Change index selectors, update to current standards (#25)
1 parent 328febe commit e1075a6

26 files changed

+899
-325
lines changed

.github/CODEOWNERS

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
# Use this file to define individuals or teams that are responsible for code in a repository.
22
# Read more: <https://help.github.com/articles/about-codeowners/>
3+
#
4+
# Order is important: the last matching pattern takes the most precedence
35

4-
* @cloudposse/engineering
6+
# These owners will be the default owners for everything
7+
* @cloudposse/engineering @cloudposse/contributors
8+
9+
# Cloud Posse must review any changes to Makefiles
10+
**/Makefile @cloudposse/engineering
11+
**/Makefile.* @cloudposse/engineering
12+
13+
# Cloud Posse must review any changes to GitHub actions
14+
.github/* @cloudposse/engineering
15+
16+
# Cloud Posse must review any changes to standard context definition
17+
**/context.tf @cloudposse/engineering

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ assignees: ''
77

88
---
99

10-
Have a question? Please checkout our [Slack Community](https://slack.cloudposse.com) in the `#geodesic` channel or visit our [Slack Archive](https://archive.sweetops.com/geodesic/).
10+
Have a question? Please checkout our [Slack Community](https://slack.cloudposse.com) or visit our [Slack Archive](https://archive.sweetops.com/).
1111

1212
[![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
1313

@@ -33,4 +33,4 @@ Explain what alternative solutions or features you've considered.
3333

3434
## Additional Context
3535

36-
Add any other context or screenshots about the feature request here.
36+
Add any other context or screenshots about the feature request here.

.github/auto-release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name-template: 'v$RESOLVED_VERSION'
2+
tag-template: '$RESOLVED_VERSION'
3+
version-template: '$MAJOR.$MINOR.$PATCH'
4+
version-resolver:
5+
major:
6+
labels:
7+
- 'major'
8+
minor:
9+
labels:
10+
- 'minor'
11+
- 'enhancement'
12+
patch:
13+
labels:
14+
- 'patch'
15+
- 'fix'
16+
- 'bugfix'
17+
- 'bug'
18+
- 'hotfix'
19+
default: 'minor'
20+
21+
categories:
22+
- title: '🚀 Enhancements'
23+
labels:
24+
- 'enhancement'
25+
- title: '🐛 Bug Fixes'
26+
labels:
27+
- 'fix'
28+
- 'bugfix'
29+
- 'bug'
30+
- 'hotfix'
31+
32+
change-template: |
33+
<details>
34+
<summary>$TITLE @$AUTHOR (#$NUMBER)</summary>
35+
36+
$BODY
37+
</details>
38+
39+
template: |
40+
$CHANGES

.github/workflows/auto-release.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: auto-release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
semver:
10+
runs-on: ubuntu-latest
11+
steps:
12+
# Drafts your next Release notes as Pull Requests are merged into "master"
13+
- uses: release-drafter/release-drafter@v5
14+
with:
15+
publish: true
16+
prerelease: false
17+
config-name: auto-release.yml
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}

.github/workflows/chatops.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v2
1111
- name: "Handle common commands"
12-
uses: cloudposse/actions/github/slash-command-dispatch@0.15.0
12+
uses: cloudposse/actions/github/slash-command-dispatch@0.16.0
1313
with:
1414
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
1515
reaction-token: ${{ secrets.GITHUB_TOKEN }}
1616
repository: cloudposse/actions
1717
commands: rebuild-readme, terraform-fmt
18-
permission: none
18+
permission: triage
1919
issue-type: pull-request
2020

2121
test:
@@ -24,13 +24,13 @@ jobs:
2424
- name: "Checkout commit"
2525
uses: actions/checkout@v2
2626
- name: "Run tests"
27-
uses: cloudposse/actions/github/slash-command-dispatch@0.15.0
27+
uses: cloudposse/actions/github/slash-command-dispatch@0.16.0
2828
with:
2929
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
3030
reaction-token: ${{ secrets.GITHUB_TOKEN }}
3131
repository: cloudposse/actions
3232
commands: test
33-
permission: none
33+
permission: triage
3434
issue-type: pull-request
3535
reactions: false
3636

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SHELL := /bin/bash
22
LAMBDA_DIR := lambda
3-
DEPS_CONTAINER := alpine:3.8
3+
DEPS_CONTAINER := alpine:3.11
44

55
# List of targets the `readme` target should call before generating the readme
66
export README_DEPS ?= docs/targets.md docs/terraform.md

README.md

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,41 @@ module "elasticsearch_cleanup" {
8686
vpc_id = module.vpc.vpc_id
8787
namespace = "eg"
8888
stage = "dev"
89-
schedule = "rate(5 minutes)"
89+
schedule = "cron(0 3 * * ? *)"
9090
}
9191
```
9292

93+
Indexes are expected to be in the format `name-date` where `date` is in the format specified by `var.index_format`.
94+
By default, all indexes except for the ones added by Kibana will be deleted based on the date part of the full
95+
index name. The actual creation date of the index is not used.
96+
97+
Index matching is done with unanchored regular expresssion, so "bar" matches index "foobarbaz".
98+
99+
- If the full index name, including the date part, matches `skip_index_re`, then the index will be skipped (never deleted).
100+
Kibana indexes are skipped by the default `skip_index_re` of `^\.kibana*` so if you specify a value for `skip_index_re`
101+
you must include the Kibana exception in your regex if you want it excepted. (Since Kibana indexes do not have a
102+
date part, this module should not delete them, but will complain about them having malformed dates if they are not excluded.)
103+
- If the index name without the trailing `-date` part matches `index_re`, then it will be cleaned up according to the date part.
104+
105+
Keep in mind that, fundamentally, this module expects indexes to be in the format of `name-date` so it will not work
106+
properly if the regexes end up selecting an index that does not end with `-date`. To avoid edge cases, it is wise not
107+
to include dashes in your index name or date format.
108+
109+
## Migration
110+
111+
Prior to version 0.10.0, this moudle had inputs `index`, which was a comma-separated list of index names or the
112+
special name "all" to indicate all but Kibana indexes, and `index_regex`, which was a regular expression for parsing
113+
index name and date parts. There was no mechanism for specifying a list of indexes to exclude.
114+
Starting with version 0.10.0 this module drops those inputs and instead takes `index_re` and `skip_index_re`,
115+
both of which are regular expressions. (You probably want to anchor your regexes to the beginning of the index name
116+
by starting with `^`).
117+
118+
| If you previously had | Now use |
119+
|----------------------|----------|
120+
|`index = "all"`| Default values for `index_re` and `skip_index_re`|
121+
|`index = "a,xb,c0"` | `index_re = "^(a\|xb\|c0)"` and `skip_index_re = "^$"`|
122+
|`index_regex = "(ipat)-(dpat)"`|`index_re = "ipat"` and be sure `index_format` is correct for your date format|
123+
93124

94125

95126

@@ -109,6 +140,7 @@ Available targets:
109140
110141
```
111142
<!-- markdownlint-restore -->
143+
<!-- markdownlint-disable -->
112144
## Module: cloudposse/terraform-aws-lambda-elasticsearch-cleanup
113145

114146
This module creates a scheduled Lambda function which will delete old
@@ -120,38 +152,44 @@ is given
120152

121153
| Name | Version |
122154
|------|---------|
123-
| terraform | >= 0.12.0, < 0.14.0 |
124-
| aws | ~> 2.0 |
125-
| null | ~> 2.0 |
126-
| template | ~> 2.0 |
155+
| terraform | >= 0.12.0 |
156+
| aws | >= 2.0 |
157+
| null | >= 2.0 |
127158

128159
## Providers
129160

130161
| Name | Version |
131162
|------|---------|
132-
| aws | ~> 2.0 |
163+
| aws | >= 2.0 |
133164

134165
## Inputs
135166

136167
| Name | Description | Type | Default | Required |
137168
|------|-------------|------|---------|:--------:|
169+
| additional\_tag\_map | Additional tags for appending to tags\_as\_list\_of\_maps. Not added to `tags`. | `map(string)` | `{}` | no |
170+
| artifact\_git\_ref | Git ref of the lambda artifact to use. Use latest version if null. | `string` | `null` | no |
138171
| artifact\_url | URL template for the remote artifact | `string` | `"https://artifacts.cloudposse.com/$${module_name}/$${git_ref}/$${filename}"` | no |
139172
| attributes | Additional attributes (e.g. `1`) | `list(string)` | `[]` | no |
173+
| context | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | <pre>object({<br> enabled = bool<br> namespace = string<br> environment = string<br> stage = string<br> name = string<br> delimiter = string<br> attributes = list(string)<br> tags = map(string)<br> additional_tag_map = map(string)<br> regex_replace_chars = string<br> label_order = list(string)<br> id_length_limit = number<br> })</pre> | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_order": [],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
140174
| delete\_after | Number of days to preserve | `number` | `15` | no |
141-
| delimiter | Delimiter to be used between `namespace`, `stage`, `name` and `attributes` | `string` | `"-"` | no |
142-
| enabled | This module will not create any resources unless enabled is set to "true" | `bool` | `true` | no |
175+
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
176+
| enabled | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
177+
| environment | Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
143178
| es\_domain\_arn | The Elasticsearch domain ARN | `string` | n/a | yes |
144179
| es\_endpoint | The Elasticsearch endpoint for the Lambda function to connect to | `string` | n/a | yes |
145180
| es\_security\_group\_id | The Elasticsearch cluster security group ID | `string` | n/a | yes |
146-
| index | Index/indices to process. Use a comma-separated list. Specify `all` to match every index except for `.kibana` or `.kibana_1` | `string` | `"all"` | no |
181+
| id\_length\_limit | Limit `id` to this many characters.<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
147182
| index\_format | Combined with 'index' variable and is used to evaluate the index age | `string` | `"%Y.%m.%d"` | no |
148-
| index\_regex | Determines regex that is used for matching index name and index date. By default it match two groups separated by hyphen. | `string` | `"([^-]+)-(.*)"` | no |
149-
| name | Solution name, e.g. 'app' or 'cluster' | `string` | `"app"` | no |
150-
| namespace | Namespace, which could be your organization name, e.g. 'eg' or 'cp' | `string` | `""` | no |
151-
| python\_version | The Python version to use | `string` | `"2.7"` | no |
183+
| index\_re | Regular Expression that matches the index names to clean up (not including trailing dash and date) | `string` | `".*"` | no |
184+
| label\_order | The naming order of the id output and Name tag.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no |
185+
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
186+
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |
187+
| python\_version | The Python version to use | `string` | `"3.7"` | no |
188+
| regex\_replace\_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
152189
| schedule | CloudWatch Events rule schedule using cron or rate expression | `string` | `"cron(0 3 * * ? *)"` | no |
190+
| skip\_index\_re | Regular Expression that matches the index names to ignore (not clean up). Takes precedence over `index_re`.<br>BY DEFAULT (when value is `null`), a pattern is used to exclude Kibana indexes.<br>Use `"^$"` if you do not want to skip any indexes. Include an exclusion for `kibana` if you<br>want to use a custom value and also exclude the kibana indexes. | `string` | `null` | no |
153191
| sns\_arn | SNS ARN to publish alerts | `string` | `""` | no |
154-
| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | `string` | `""` | no |
192+
| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
155193
| subnet\_ids | Subnet IDs | `list(string)` | n/a | yes |
156194
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no |
157195
| timeout | Timeout for Lambda function in seconds | `number` | `300` | no |
@@ -165,6 +203,7 @@ is given
165203
| lambda\_function\_source\_code\_size | The size in bytes of the function .zip file |
166204
| security\_group\_id | Security Group ID of the Lambda Function |
167205

206+
<!-- markdownlint-restore -->
168207

169208

170209

README.yaml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,42 @@ usage: |2-
4343
vpc_id = module.vpc.vpc_id
4444
namespace = "eg"
4545
stage = "dev"
46-
schedule = "rate(5 minutes)"
46+
schedule = "cron(0 3 * * ? *)"
4747
}
4848
```
49+
50+
Indexes are expected to be in the format `name-date` where `date` is in the format specified by `var.index_format`.
51+
By default, all indexes except for the ones added by Kibana will be deleted based on the date part of the full
52+
index name. The actual creation date of the index is not used.
53+
54+
Index matching is done with unanchored regular expresssion, so "bar" matches index "foobarbaz".
55+
56+
- If the full index name, including the date part, matches `skip_index_re`, then the index will be skipped (never deleted).
57+
Kibana indexes are skipped by the default `skip_index_re` of `^\.kibana*` so if you specify a value for `skip_index_re`
58+
you must include the Kibana exception in your regex if you want it excepted. (Since Kibana indexes do not have a
59+
date part, this module should not delete them, but will complain about them having malformed dates if they are not excluded.)
60+
- If the index name without the trailing `-date` part matches `index_re`, then it will be cleaned up according to the date part.
61+
62+
Keep in mind that, fundamentally, this module expects indexes to be in the format of `name-date` so it will not work
63+
properly if the regexes end up selecting an index that does not end with `-date`. To avoid edge cases, it is wise not
64+
to include dashes in your index name or date format.
65+
66+
## Migration
67+
68+
Prior to version 0.10.0, this moudle had inputs `index`, which was a comma-separated list of index names or the
69+
special name "all" to indicate all but Kibana indexes, and `index_regex`, which was a regular expression for parsing
70+
index name and date parts. There was no mechanism for specifying a list of indexes to exclude.
71+
Starting with version 0.10.0 this module drops those inputs and instead takes `index_re` and `skip_index_re`,
72+
both of which are regular expressions. (You probably want to anchor your regexes to the beginning of the index name
73+
by starting with `^`).
74+
75+
| If you previously had | Now use |
76+
|----------------------|----------|
77+
|`index = "all"`| Default values for `index_re` and `skip_index_re`|
78+
|`index = "a,xb,c0"` | `index_re = "^(a\|xb\|c0)"` and `skip_index_re = "^$"`|
79+
|`index_regex = "(ipat)-(dpat)"`|`index_re = "ipat"` and be sure `index_format` is correct for your date format|
80+
81+
4982
include:
5083
- docs/targets.md
5184
- docs/terraform.md

0 commit comments

Comments
 (0)