Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update bootstrapping s3 resources for aws provider v4 #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bootstrap/.terraform-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.14.7
1.2.1
36 changes: 1 addition & 35 deletions bootstrap/s3_bucket.tf
Original file line number Diff line number Diff line change
@@ -1,41 +1,7 @@
resource "aws_s3_bucket" "bucket" {
bucket = var.bucket_name
acl = "private"

bucket = var.bucket_name
force_destroy = "false"

lifecycle_rule {
prefix = ""
enabled = "true"

noncurrent_version_transition {
days = "30"
storage_class = "STANDARD_IA"
}

noncurrent_version_transition {
days = "60"
storage_class = "GLACIER"
}

noncurrent_version_expiration {
days = "90"
}
}

server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
kms_master_key_id = aws_kms_key.s3.arn
sse_algorithm = "aws:kms"
}
}
}

versioning {
enabled = "true"
}

# This does not use default tag map merging because bootstrapping is special
# You should use default tag map merging elsewhere
tags = {
Expand Down
4 changes: 4 additions & 0 deletions bootstrap/s3_bucket_acl.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "aws_s3_bucket_acl" "bucket" {
bucket = aws_s3_bucket.bucket.id
acl = "private"
}
27 changes: 27 additions & 0 deletions bootstrap/s3_bucket_lifecycle_configuration.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
resource "aws_s3_bucket_lifecycle_configuration" "bucket" {
bucket = aws_s3_bucket.bucket.id
expected_bucket_owner = var.aws_account_id

rule {
id = "default"
status = "Enabled"

filter {
prefix = ""
}

noncurrent_version_transition {
noncurrent_days = "30"
storage_class = "STANDARD_IA"
}

noncurrent_version_transition {
noncurrent_days = "60"
storage_class = "GLACIER"
}

noncurrent_version_expiration {
noncurrent_days = "90"
}
}
}
10 changes: 10 additions & 0 deletions bootstrap/s3_bucket_server_side_encryption_configuration.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "aws_s3_bucket_server_side_encryption_configuration" "bucket" {
bucket = aws_s3_bucket.bucket.bucket

rule {
apply_server_side_encryption_by_default {
kms_master_key_id = aws_kms_key.s3.arn
sse_algorithm = "aws:kms"
}
}
}
7 changes: 7 additions & 0 deletions bootstrap/s3_bucket_versioning.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "aws_s3_bucket_versioning" "bucket" {
bucket = aws_s3_bucket.bucket.id

versioning_configuration {
status = "Enabled"
}
}
4 changes: 2 additions & 2 deletions bootstrap/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.31.0"
version = "~> 4.15.1"
}
}

required_version = ">= 0.14.7"
required_version = ">= 1.2.1"
}