Skip to content
This repository was archived by the owner on Sep 27, 2024. It is now read-only.

Commit 6afcfc3

Browse files
configure precommit ci (#2)
* Adding pre-commit config * Adding markdown files * [pre-commit.ci lite] apply automatic fixes * Fix pre-commit * Snyk fix --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent b458869 commit 6afcfc3

File tree

9 files changed

+204
-68
lines changed

9 files changed

+204
-68
lines changed

.github/workflows/pre-commit.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
on:
2+
pull_request:
3+
push:
4+
branches: [main]
5+
6+
jobs:
7+
pre_commit:
8+
name: Run pre-commit and commit any autocorrections
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- name: Setup Terraform
13+
uses: hashicorp/setup-terraform@v3
14+
with:
15+
terraform_version: 1.6.6
16+
- name: Setup Terragrunt
17+
uses: autero1/action-terragrunt@v1.1.0
18+
with:
19+
terragrunt_version: 0.54.8
20+
# To avoid rate-limiting
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
- uses: terraform-linters/setup-tflint@v3
23+
name: TFLint - Setup
24+
with:
25+
tflint_version: latest
26+
27+
- name: TFLint - Init
28+
run: tflint --init
29+
env:
30+
# https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md#avoiding-rate-limiting
31+
GITHUB_TOKEN: ${{ github.token }}
32+
- name: TFLint - Show version
33+
run: tflint --version
34+
- uses: actions/setup-python@v4
35+
with:
36+
python-version: 3.x
37+
- name: Terraform Docs - Install
38+
run: |
39+
curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.17.0/terraform-docs-v0.17.0-$(uname)-amd64.tar.gz
40+
tar -xzf terraform-docs.tar.gz -- terraform-docs
41+
chmod +x terraform-docs
42+
echo $PATH
43+
mv terraform-docs /usr/local/bin/terraform-docs
44+
terraform-docs --version
45+
- uses: pre-commit/action@v3.0.0
46+
- uses: pre-commit-ci/lite-action@v1.0.1
47+
if: always()

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.terraform*
22
.DS_Store
3-
terraform.*
3+
terraform.*

.pre-commit-config.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,30 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.4.0
5+
rev: v4.5.0
66
hooks:
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
99
- id: check-yaml
1010
args: ["--allow-multiple-documents"]
1111
- id: check-added-large-files
1212
- repo: https://github.com/antonbabenko/pre-commit-terraform
13-
rev: v1.77.0 # Get the latest from: https://github.com/antonbabenko/pre-commit-terraform/releases
13+
rev: v1.85.0 # Get the latest from: https://github.com/antonbabenko/pre-commit-terraform/releases
1414
hooks:
1515
- id: terraform_fmt # args: ["--enable require-variable-braces,deprecate-which"]
1616
- id: terraform_tflint
17-
exclude: .*
17+
args:
18+
- "--args=--fix"
1819
- id: terragrunt_fmt
1920
- id: terraform_docs
21+
ci:
22+
autofix_commit_msg: |
23+
[pre-commit.ci] auto fixes from pre-commit.com hooks
24+
25+
for more information, see https://pre-commit.ci
26+
autofix_prs: true
27+
autoupdate_branch: ''
28+
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
29+
autoupdate_schedule: weekly
30+
skip: [terraform_fmt, terraform_tflint, terragrunt_fmt, terraform_docs]
31+
submodules: false

LICENSE.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# License
2+
3+
As a work of the [United States government](https://www.usa.gov/), this project
4+
is in the public domain within the United States of America.
5+
6+
Additionally, we waive copyright and related rights in the work worldwide
7+
through the CC0 1.0 Universal public domain dedication.
8+
9+
## CC0 1.0 Universal Summary
10+
11+
This is a human-readable summary of the [Legal Code (read the full
12+
text)](https://creativecommons.org/publicdomain/zero/1.0/legalcode).
13+
14+
### No Copyright
15+
16+
The person who associated a work with this deed has dedicated the work to the
17+
public domain by waiving all of their rights to the work worldwide under
18+
copyright law, including all related and neighboring rights, to the extent
19+
allowed by law.
20+
21+
You can copy, modify, distribute, and perform the work, even for commercial
22+
purposes, all without asking permission.
23+
24+
### Other Information
25+
26+
In no way are the patent or trademark rights of any person affected by CC0, nor
27+
are the rights that other persons may have in the work or in how the work is
28+
used, such as publicity or privacy rights.
29+
30+
Unless expressly stated otherwise, the person who associated a work with this
31+
deed makes no warranties about the work, and disclaims liability for all uses
32+
of the work, to the fullest extent permitted by applicable law. When using or
33+
citing the work, you should not imply endorsement by the author or the
34+
affirmer.

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,47 @@
11
# batcave-tf-redis
2+
3+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
4+
## Requirements
5+
6+
| Name | Version |
7+
|------|---------|
8+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.2 |
9+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.61.0 |
10+
11+
## Providers
12+
13+
| Name | Version |
14+
|------|---------|
15+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.61.0 |
16+
17+
## Modules
18+
19+
No modules.
20+
21+
## Resources
22+
23+
| Name | Type |
24+
|------|------|
25+
| [aws_elasticache_cluster.redis](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_cluster) | resource |
26+
| [aws_subnet.private](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource |
27+
28+
## Inputs
29+
30+
| Name | Description | Type | Default | Required |
31+
|------|-------------|------|---------|:--------:|
32+
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | n/a | `string` | `""` | no |
33+
| <a name="input_engine"></a> [engine](#input\_engine) | n/a | `string` | `""` | no |
34+
| <a name="input_engine_version"></a> [engine\_version](#input\_engine\_version) | n/a | `string` | `""` | no |
35+
| <a name="input_node_type"></a> [node\_type](#input\_node\_type) | n/a | `string` | `"cache.m4.large"` | no |
36+
| <a name="input_num_cache_nodes"></a> [num\_cache\_nodes](#input\_num\_cache\_nodes) | n/a | `number` | `1` | no |
37+
| <a name="input_parameter_group_name"></a> [parameter\_group\_name](#input\_parameter\_group\_name) | n/a | `string` | `""` | no |
38+
| <a name="input_port"></a> [port](#input\_port) | n/a | `number` | `6379` | no |
39+
| <a name="input_security_group_ids"></a> [security\_group\_ids](#input\_security\_group\_ids) | n/a | `list(string)` | `[]` | no |
40+
| <a name="input_snapshot_retention_limit"></a> [snapshot\_retention\_limit](#input\_snapshot\_retention\_limit) | The number of days for which ElastiCache will retain automatic cache cluster snapshots before deleting them. For example, if you set SnapshotRetentionLimit to 5, then a snapshot that was taken today will be retained for 5 days before being deleted. | `number` | `7` | no |
41+
| <a name="input_tags"></a> [tags](#input\_tags) | n/a | `map(string)` | <pre>{<br> "Owner": "Batcave"<br>}</pre> | no |
42+
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | n/a | `string` | n/a | yes |
43+
44+
## Outputs
45+
46+
No outputs.
47+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

SECURITY.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Security and Responsible Disclosure Policy
2+
3+
*Submit a vulnerability:* Unfortunately, we cannot accept secure submissions via
4+
email or via GitHub Issues. Please use our website to submit vulnerabilities at
5+
[https://hhs.responsibledisclosure.com](https://hhs.responsibledisclosure.com).
6+
HHS maintains an acknowledgements page to recognize your efforts on behalf of
7+
the American public, but you are also welcome to submit anonymously.
8+
9+
Review the HHS Disclosure Policy and websites in scope:
10+
[https://www.hhs.gov/vulnerability-disclosure-policy/index.html](https://www.hhs.gov/vulnerability-disclosure-policy/index.html).
11+
12+
This policy describes *what systems and types of research* are covered under this
13+
policy, *how to send* us vulnerability reports, and *how long* we ask security
14+
researchers to wait before publicly disclosing vulnerabilities.
15+
16+
If you have other cybersecurity related questions, please contact us at
17+
[csirc@hhs.gov.](mailto:csirc@hhs.gov).

main.tf

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,33 @@
1+
terraform {
2+
required_providers {
3+
aws = {
4+
source = "hashicorp/aws"
5+
version = ">= 4.61.0"
6+
}
7+
}
8+
required_version = ">= 1.2"
19

2-
# Configure the AWS Provider
3-
// provider "aws" {
4-
// region = "us-east-1"
5-
// }
6-
7-
8-
10+
}
911

1012
resource "aws_elasticache_cluster" "redis" {
11-
cluster_id = var.cluster_id
12-
engine = var.engine
13-
engine_version = var.engine_version
14-
node_type = var.node_type
15-
num_cache_nodes = var.num_cache_nodes
16-
parameter_group_name = var.parameter_group_name
17-
port = var.port
18-
security_group_ids = var.security_group_ids
19-
20-
subnet_group_name = aws_subnet.private.name
21-
22-
23-
tags = var.tags
13+
cluster_id = var.cluster_id
14+
engine = var.engine
15+
engine_version = var.engine_version
16+
node_type = var.node_type
17+
num_cache_nodes = var.num_cache_nodes
18+
parameter_group_name = var.parameter_group_name
19+
port = var.port
20+
security_group_ids = var.security_group_ids
21+
subnet_group_name = aws_subnet.private.name
22+
tags = var.tags
23+
snapshot_retention_limit = var.snapshot_retention_limit
2424
}
2525

2626
resource "aws_subnet" "private" {
2727
vpc_id = var.vpc_id
2828
cidr_block = "10.202.196.0/23"
2929
}
3030

31-
# private subnets
32-
data "aws_subnets" "private" {
33-
filter {
34-
name = "tag:Name"
35-
values = [ "${var.project}-*-${var.env}-private-*"]
36-
}
37-
}
3831

3932

4033

@@ -44,11 +37,3 @@ data "aws_subnets" "private" {
4437
// }
4538
// )
4639
// }
47-
48-
49-
50-
51-
52-
53-
54-

output.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
// output "db_subnet_group_name" {
33
// description = "The db subnet group name"
44
// value = module.redis.subnet_group_namee
5-
// }
5+
// }

variables.tf

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,35 @@
1-
variable "env" {
2-
default = "dev"
1+
variable "vpc_id" {
2+
type = string
33
}
44

5-
variable "project" {
6-
default = "eppe"
7-
}
8-
9-
variable "vpc_id" {}
10-
115
variable "cluster_id" {
12-
default = ""
13-
type = string
6+
default = ""
7+
type = string
148
}
159

1610
variable "engine" {
17-
default = ""
18-
type = string
11+
default = ""
12+
type = string
1913
}
2014

2115
variable "engine_version" {
22-
default = ""
23-
type = string
16+
default = ""
17+
type = string
2418
}
2519

2620
variable "node_type" {
27-
default = ""
28-
type = string
21+
type = string
22+
default = "cache.m4.large"
2923
}
3024

3125
variable "num_cache_nodes" {
32-
default = 1
33-
type = number
26+
default = 1
27+
type = number
3428
}
3529

3630
variable "parameter_group_name" {
37-
default = ""
38-
type = string
31+
default = ""
32+
type = string
3933
}
4034

4135
variable "security_group_ids" {
@@ -44,13 +38,8 @@ variable "security_group_ids" {
4438
}
4539

4640
variable "port" {
47-
default = 6379
48-
type = number
49-
}
50-
51-
variable "subnet_ids" {
52-
type = list(string)
53-
default = []
41+
default = 6379
42+
type = number
5443
}
5544

5645
// variable "subnet_lookup_overrides" {
@@ -64,4 +53,10 @@ variable "tags" {
6453
default = {
6554
Owner = "Batcave"
6655
}
67-
}
56+
}
57+
58+
variable "snapshot_retention_limit" {
59+
type = number
60+
default = 7
61+
description = "The number of days for which ElastiCache will retain automatic cache cluster snapshots before deleting them. For example, if you set SnapshotRetentionLimit to 5, then a snapshot that was taken today will be retained for 5 days before being deleted."
62+
}

0 commit comments

Comments
 (0)