-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Chore] Replace S3 deprecated syntax (#68)
* [WIP] Replace deprecated syntax for s3-private * [WIP] Replace deprecated syntax for s3-public * [WIP] Sanitize the string using replace function * [WIP] Add extensions recommendations * [WIP] Turn on formatOnSave for terraform file in the repo * [WIP] Update gitignore
- Loading branch information
1 parent
8b95b42
commit d3840ef
Showing
6 changed files
with
78 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ | |
!/tmp/pids/.keep | ||
|
||
# Special\Personal dev setup | ||
.vscode/* | ||
/.idea | ||
|
||
# os | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["hashicorp.terraform"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"[terraform]": { | ||
"editor.defaultFormatter": "hashicorp.terraform", | ||
"editor.formatOnSave": true, | ||
"editor.formatOnSaveMode": "file" | ||
}, | ||
|
||
"[terraform-vars]": { | ||
"editor.defaultFormatter": "hashicorp.terraform", | ||
"editor.formatOnSave": true, | ||
"editor.formatOnSaveMode": "file" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
resource "aws_kms_alias" "a" { | ||
name = "alias/${var.project}/${var.environment}/${var.alias}" | ||
name = replace("alias/${var.project}/${var.environment}/${var.alias}", "/[^a-zA-Z0-9:///_-]+/", "-") | ||
target_key_id = aws_kms_key.key.key_id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,34 @@ | ||
resource "aws_s3_bucket" "main" { | ||
bucket = var.bucket_name | ||
acl = "public-read" | ||
tags = { | ||
Name = var.bucket_name | ||
Project = var.project | ||
Environment = var.environment | ||
} | ||
} | ||
|
||
versioning { | ||
enabled = var.versioning | ||
resource "aws_s3_bucket_versioning" "main-bucket-versioning" { | ||
bucket = aws_s3_bucket.main.id | ||
versioning_configuration { | ||
status = var.versioning ? "Enabled" : "Disabled" | ||
} | ||
} | ||
|
||
# Move data to a cheaper storage class after a period of time | ||
lifecycle_rule { | ||
enabled = var.primary_storage_class_retention == 0 ? false : false | ||
resource "aws_s3_bucket_acl" "main-bucket-data-acl" { | ||
bucket = aws_s3_bucket.main.id | ||
acl = "public-read" | ||
} | ||
|
||
# Move data to a cheaper storage class after a period of time | ||
resource "aws_s3_bucket_lifecycle_configuration" "main-bucket-lifecycle-rule" { | ||
bucket = aws_s3_bucket.main.id | ||
|
||
rule { | ||
id = "primary-storage-class-retention" | ||
status = var.primary_storage_class_retention == 0 ? "Disabled" : "Enabled" | ||
noncurrent_version_transition { | ||
days = var.primary_storage_class_retention == 0 ? 365 : var.primary_storage_class_retention | ||
storage_class = "STANDARD_IA" | ||
noncurrent_days = var.primary_storage_class_retention == 0 ? 365 : var.primary_storage_class_retention | ||
storage_class = "STANDARD_IA" | ||
} | ||
} | ||
|
||
tags = { | ||
Name = var.bucket_name | ||
Project = var.project | ||
Environment = var.environment | ||
} | ||
} |