Skip to content

Commit 48147d6

Browse files
bushong1pre-commit-ci-lite[bot]github-actions[bot]
authored
Running pre-commit on repo (#15)
* Running pre-commit on repo * Ignoring terragrunt for pre-commit ci * Pre-commit github actions * Update action name * [pre-commit.ci lite] apply automatic fixes * Add README * move tf docs to dedicated job, install tflint * terraform-docs: automated action * Remove terraform-docs from pre-commit * Tweak names * Re-enable tflint * tflint autofix * Upgrade * Bump tflint version * tweak tflint * Add help output * Fix autofix * [pre-commit.ci lite] apply automatic fixes * Fixing variable type to bool * Update license and security markdown * Add ci order * Incorporate tf_docs into pre-commit for ease of autocorrect * Reset readme * [pre-commit.ci lite] apply automatic fixes * cleanup --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent e05a042 commit 48147d6

File tree

7 files changed

+172
-23
lines changed

7 files changed

+172
-23
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()

.pre-commit-config.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
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
2021
ci:
@@ -26,5 +27,5 @@ ci:
2627
autoupdate_branch: ''
2728
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
2829
autoupdate_schedule: weekly
29-
skip: []
30+
skip: [terraform_fmt, terraform_tflint, terragrunt_fmt, terraform_docs]
3031
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: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# batcave-tf-buckets
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_s3_bucket.landing_zone_buckets](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
26+
| [aws_s3_bucket_lifecycle_configuration.lifecycle_expiration_days](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |
27+
| [aws_s3_bucket_ownership_controls.landing_zone_buckets](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |
28+
| [aws_s3_bucket_policy.bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
29+
| [aws_s3_bucket_public_access_block.landing_zone_buckets](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |
30+
| [aws_s3_bucket_server_side_encryption_configuration.bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource |
31+
| [aws_s3_bucket_versioning.bucket_versioning](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_versioning) | resource |
32+
33+
## Inputs
34+
35+
| Name | Description | Type | Default | Required |
36+
|------|-------------|------|---------|:--------:|
37+
| <a name="input_force_destroy"></a> [force\_destroy](#input\_force\_destroy) | n/a | `bool` | `true` | no |
38+
| <a name="input_lifecycle_expiration_days"></a> [lifecycle\_expiration\_days](#input\_lifecycle\_expiration\_days) | Number of days for object lifecycle to expire the objects in dev env. Defaults to 0, which disables the rule | `number` | `"0"` | no |
39+
| <a name="input_replication_permission_iam_role"></a> [replication\_permission\_iam\_role](#input\_replication\_permission\_iam\_role) | n/a | `string` | `null` | no |
40+
| <a name="input_s3_bucket_kms_key_id"></a> [s3\_bucket\_kms\_key\_id](#input\_s3\_bucket\_kms\_key\_id) | KMS Key used to encrypt s3 buckets. Defaults to null, which uses default aws/s3 key | `string` | `null` | no |
41+
| <a name="input_s3_bucket_names"></a> [s3\_bucket\_names](#input\_s3\_bucket\_names) | n/a | `list(string)` | `[]` | no |
42+
| <a name="input_sse_algorithm"></a> [sse\_algorithm](#input\_sse\_algorithm) | The server-side encryption algorithm to use. Valid values are AES256 and aws:kms, defaults to aws:kms. | `string` | `"aws:kms"` | no |
43+
| <a name="input_tags"></a> [tags](#input\_tags) | n/a | `map(any)` | `{}` | no |
44+
| <a name="input_versioning_enabled"></a> [versioning\_enabled](#input\_versioning\_enabled) | n/a | `bool` | `false` | no |
45+
46+
## Outputs
47+
48+
| Name | Description |
49+
|------|-------------|
50+
| <a name="output_bucket_verisioning"></a> [bucket\_verisioning](#output\_bucket\_verisioning) | n/a |
51+
| <a name="output_s3_buckets"></a> [s3\_buckets](#output\_s3\_buckets) | n/a |
52+
<!-- 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: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# S3 buckets for landing zone
21
terraform {
32
required_providers {
43
aws = {
@@ -7,7 +6,6 @@ terraform {
76
}
87
}
98
required_version = ">= 1.2"
10-
119
}
1210

1311
resource "aws_s3_bucket" "landing_zone_buckets" {
@@ -18,24 +16,23 @@ resource "aws_s3_bucket" "landing_zone_buckets" {
1816
}
1917

2018
locals {
21-
buckets = aws_s3_bucket.landing_zone_buckets
2219
}
2320

2421
resource "aws_s3_bucket_ownership_controls" "landing_zone_buckets" {
2522
## Iterate over the list from var's to avoid some chicken/egg problems
26-
for_each = toset(var.s3_bucket_names)
23+
for_each = toset(var.s3_bucket_names)
2724
## Refer to the id from the bucket resource to retain the dependency
28-
bucket = aws_s3_bucket.landing_zone_buckets[each.value].id
25+
bucket = aws_s3_bucket.landing_zone_buckets[each.value].id
2926
rule {
3027
object_ownership = "BucketOwnerEnforced"
3128
}
3229
}
3330

3431
resource "aws_s3_bucket_public_access_block" "landing_zone_buckets" {
3532
## Iterate over the list from var's to avoid some chicken/egg problems
36-
for_each = toset(var.s3_bucket_names)
33+
for_each = toset(var.s3_bucket_names)
3734
## Refer to the id from the bucket resource to retain the dependency
38-
bucket = aws_s3_bucket.landing_zone_buckets[each.value].id
35+
bucket = aws_s3_bucket.landing_zone_buckets[each.value].id
3936

4037
block_public_acls = true
4138
block_public_policy = true
@@ -47,7 +44,7 @@ resource "aws_s3_bucket_versioning" "bucket_versioning" {
4744
## Iterate over the list from var's to avoid some chicken/egg problems
4845
for_each = var.versioning_enabled ? toset(var.s3_bucket_names) : []
4946
## Refer to the id from the bucket resource to retain the dependency
50-
bucket = aws_s3_bucket.landing_zone_buckets[each.value].id
47+
bucket = aws_s3_bucket.landing_zone_buckets[each.value].id
5148
versioning_configuration {
5249
status = "Enabled"
5350
}
@@ -57,7 +54,7 @@ resource "aws_s3_bucket_policy" "bucket" {
5754
## Iterate over the list from var's to avoid some chicken/egg problems
5855
for_each = toset(var.s3_bucket_names)
5956
## Refer to the id from the bucket resource to retain the dependency
60-
bucket = aws_s3_bucket.landing_zone_buckets[each.value].id
57+
bucket = aws_s3_bucket.landing_zone_buckets[each.value].id
6158

6259
policy = jsonencode({
6360
Version = "2012-10-17"
@@ -70,7 +67,7 @@ resource "aws_s3_bucket_policy" "bucket" {
7067
Action = "s3:*"
7168
Resource = [
7269
"${aws_s3_bucket.landing_zone_buckets[each.value].arn}/*",
73-
"${aws_s3_bucket.landing_zone_buckets[each.value].arn}",
70+
aws_s3_bucket.landing_zone_buckets[each.value].arn,
7471
]
7572
Condition = {
7673
Bool = {
@@ -85,7 +82,7 @@ resource "aws_s3_bucket_policy" "bucket" {
8582
Action = "s3:*"
8683
Resource = [
8784
"${aws_s3_bucket.landing_zone_buckets[each.value].arn}/*",
88-
"${aws_s3_bucket.landing_zone_buckets[each.value].arn}",
85+
aws_s3_bucket.landing_zone_buckets[each.value].arn,
8986
]
9087
Condition = {
9188
NumericLessThan = {
@@ -99,7 +96,7 @@ resource "aws_s3_bucket_policy" "bucket" {
9996
Sid = "ReplicaPermissionsFiles"
10097
Effect = "Allow"
10198
Principal = {
102-
"AWS" : "${var.replication_permission_iam_role}"
99+
"AWS" : var.replication_permission_iam_role
103100
}
104101
Action = ["s3:ReplicateObject", "s3:ReplicateDelete", "s3:ReplicateTags"]
105102
Resource = [
@@ -110,11 +107,11 @@ resource "aws_s3_bucket_policy" "bucket" {
110107
Sid = "ReplicaPermissions"
111108
Effect = "Allow"
112109
Principal = {
113-
"AWS" : "${var.replication_permission_iam_role}"
110+
"AWS" : var.replication_permission_iam_role
114111
}
115112
Action = ["s3:GetReplicationConfiguration", "s3:ListBucket"]
116113
Resource = [
117-
"${aws_s3_bucket.landing_zone_buckets[each.value].arn}",
114+
aws_s3_bucket.landing_zone_buckets[each.value].arn,
118115
]
119116
}
120117
]
@@ -126,7 +123,7 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "bucket" {
126123
## Iterate over the list from var's to avoid some chicken/egg problems
127124
for_each = toset(var.s3_bucket_names)
128125
## Refer to the id from the bucket resource to retain the dependency
129-
bucket = aws_s3_bucket.landing_zone_buckets[each.value].id
126+
bucket = aws_s3_bucket.landing_zone_buckets[each.value].id
130127

131128
rule {
132129
apply_server_side_encryption_by_default {
@@ -141,7 +138,7 @@ resource "aws_s3_bucket_lifecycle_configuration" "lifecycle_expiration_days" {
141138
## Iterate over the list from var's to avoid some chicken/egg problems
142139
for_each = var.lifecycle_expiration_days > 0 ? toset(var.s3_bucket_names) : []
143140
## Refer to the id from the bucket resource to retain the dependency
144-
bucket = aws_s3_bucket.landing_zone_buckets[each.value].id
141+
bucket = aws_s3_bucket.landing_zone_buckets[each.value].id
145142

146143
dynamic "rule" {
147144
for_each = var.lifecycle_expiration_days > 0 ? [1] : []

variables.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ variable "s3_bucket_names" {
55

66
variable "force_destroy" {
77
default = true
8+
type = bool
89
}
910

1011
variable "tags" {
@@ -36,6 +37,6 @@ variable "versioning_enabled" {
3637
}
3738

3839
variable "replication_permission_iam_role" {
39-
type = string
40-
default = null
41-
}
40+
type = string
41+
default = null
42+
}

0 commit comments

Comments
 (0)