Skip to content

Commit 0e0e61e

Browse files
authored
Update documentation and add examples (#16)
1 parent 708804f commit 0e0e61e

File tree

10 files changed

+131
-1
lines changed

10 files changed

+131
-1
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ indent_style = space
2020
max_line_length = off
2121

2222
[*.md]
23-
max_line_length = 0
23+
max_line_length = off
2424
trim_trailing_whitespace = false
2525

2626
[*.yml]

.github/workflows/trivy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ jobs:
2828
format: 'table'
2929
exit-code: '1'
3030
hide-progress: false
31+
skip-dirs: 'examples'

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
11
# AWS Secure S3 Terraform module
22

33
Terraform module which creates a S3 bucket on AWS with secure defaults.
4+
5+
## Usage
6+
7+
The simplest usage of this module is shown below. It only requires to pass in the `bucket_name`.
8+
9+
```hcl
10+
module "terraform_state_s3_bucket" {
11+
source = "ultratendency/secure-s3-bucket/aws"
12+
version = "1.0.0"
13+
14+
bucket_name = "secure-bucket"
15+
}
16+
```
17+
18+
A complete example looks like the following, where all inputs are configured.
19+
20+
```hcl
21+
module "terraform_state_s3_bucket" {
22+
source = "ultratendency/secure-s3-bucket/aws"
23+
version = "1.0.0"
24+
25+
bucket_name = "secure-bucket"
26+
27+
bucket_lifecycle_configuration_rule_noncurrent_version_expiration_noncurrent_days = 45
28+
bucket_lifecycle_configuration_rule_noncurrent_version_first_transition_noncurrent_days = 15
29+
bucket_lifecycle_configuration_rule_noncurrent_version_first_transition_storage_class = "ONEZONE_IA"
30+
bucket_lifecycle_configuration_rule_noncurrent_version_second_transition_noncurrent_days = 30
31+
bucket_lifecycle_configuration_rule_noncurrent_version_second_transition_storage_class = "GLACIER_IR"
32+
bucket_lifecycle_configuration_rule_abort_incomplete_multipart_upload_days_after_initiation = 14
33+
34+
aws_kms_key_enable_key_rotation = false
35+
aws_kms_key_multi_region = true
36+
37+
aws_s3_bucket_public_access_block_block_public_acls = false
38+
aws_s3_bucket_public_access_block_block_public_policy = false
39+
aws_s3_bucket_public_access_block_ignore_public_acls = false
40+
aws_s3_bucket_public_access_block_restrict_public_buckets = false
41+
}
42+
```

checkov-config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ skip-check:
66
- CKV_AWS_18
77
- CKV_AWS_144
88
- CKV2_AWS_62
9+
# As we're using the Terraform Registry
10+
- CKV_TF_1

examples/complete/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Complete bucket
2+
3+
The configuration in this directory creates a S3 bucket with all input set to different values
4+
than the defaults.
5+
6+
## Usage
7+
8+
To run this example you need to execute:
9+
10+
```bash
11+
terraform init
12+
terraform plan
13+
terraform apply
14+
```
15+
16+
Note that this example may create resources which can cost money (AWS Elastic IP, for example).
17+
Run `terraform destroy`` when you don't need these resources.

examples/complete/main.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
provider "aws" {
2+
region = "eu-central-1"
3+
}
4+
5+
module "terraform_state_s3_bucket" {
6+
source = "ultratendency/secure-s3-bucket/aws"
7+
version = "1.0.0"
8+
9+
bucket_name = "secure-bucket"
10+
11+
bucket_lifecycle_configuration_rule_noncurrent_version_expiration_noncurrent_days = 45
12+
bucket_lifecycle_configuration_rule_noncurrent_version_first_transition_noncurrent_days = 15
13+
bucket_lifecycle_configuration_rule_noncurrent_version_first_transition_storage_class = "ONEZONE_IA"
14+
bucket_lifecycle_configuration_rule_noncurrent_version_second_transition_noncurrent_days = 30
15+
bucket_lifecycle_configuration_rule_noncurrent_version_second_transition_storage_class = "GLACIER_IR"
16+
bucket_lifecycle_configuration_rule_abort_incomplete_multipart_upload_days_after_initiation = 14
17+
18+
aws_kms_key_enable_key_rotation = false
19+
aws_kms_key_multi_region = true
20+
21+
aws_s3_bucket_public_access_block_block_public_acls = false
22+
aws_s3_bucket_public_access_block_block_public_policy = false
23+
aws_s3_bucket_public_access_block_ignore_public_acls = false
24+
aws_s3_bucket_public_access_block_restrict_public_buckets = false
25+
}

examples/complete/versions.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 5.0"
8+
}
9+
}
10+
}

examples/simple/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Simple bucket
2+
3+
The configuration in this directory creates a S3 bucket with all default values.
4+
5+
## Usage
6+
7+
To run this example you need to execute:
8+
9+
```bash
10+
terraform init
11+
terraform plan
12+
terraform apply
13+
```
14+
15+
Note that this example may create resources which can cost money (AWS Elastic IP, for example).
16+
Run `terraform destroy`` when you don't need these resources.

examples/simple/main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
provider "aws" {
2+
region = "eu-central-1"
3+
}
4+
5+
module "terraform_state_s3_bucket" {
6+
source = "ultratendency/secure-s3-bucket/aws"
7+
version = "1.0.0"
8+
9+
bucket_name = "secure-bucket"
10+
}

examples/simple/versions.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 5.0"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)