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

Dev #3

Merged
merged 1 commit into from
May 9, 2024
Merged
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
43 changes: 43 additions & 0 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions aws_caller_identity.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "aws_caller_identity" "main" {

}
1 change: 1 addition & 0 deletions aws_canonical_user_id.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data "aws_canonical_user_id" "main" {}
3 changes: 3 additions & 0 deletions aws_region.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "aws_region" "main" {

}
13 changes: 13 additions & 0 deletions aws_s3_bucket.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "aws_s3_bucket" "main" {
bucket = lower("${data.aws_caller_identity.main.account_id}-${local.organization}")
force_destroy = true
tags = {
caller_identity_account_arn = data.aws_caller_identity.main.arn
caller_identity_account_id = data.aws_caller_identity.main.account_id
caller_identity_user_id = data.aws_caller_identity.main.user_id
canonical_user_id = data.aws_canonical_user_id.main.id
organization = local.organization
region = data.aws_region.main.name
workspace = terraform.workspace
}
}
4 changes: 4 additions & 0 deletions aws_s3_bucket_acl.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "aws_s3_bucket_acl" "main" {
acl = "private"
bucket = aws_s3_bucket_ownership_controls.main.bucket
}
5 changes: 5 additions & 0 deletions aws_s3_bucket_logging.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "aws_s3_bucket_logging" "main" {
bucket = aws_s3_bucket.main.bucket
target_bucket = aws_s3_bucket.main.bucket
target_prefix = aws_s3_object.log.key
}
6 changes: 6 additions & 0 deletions aws_s3_bucket_ownership_controls.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "aws_s3_bucket_ownership_controls" "main" {
bucket = aws_s3_bucket.main.bucket
rule {
object_ownership = "BucketOwnerEnforced"
}
}
7 changes: 7 additions & 0 deletions aws_s3_bucket_public_access_block.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "aws_s3_bucket_public_access_block" "main" {
block_public_acls = true
block_public_policy = true
bucket = aws_s3_bucket_acl.main.bucket
ignore_public_acls = true
restrict_public_buckets = true
}
8 changes: 8 additions & 0 deletions aws_s3_bucket_versioning.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "aws_s3_bucket_versioning" "main" {
bucket = aws_s3_bucket.main.bucket
expected_bucket_owner = data.aws_caller_identity.main.account_id
versioning_configuration {
mfa_delete = "Disabled"
status = "Disabled"
}
}
8 changes: 8 additions & 0 deletions aws_s3_object.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "aws_s3_object" "log" {
acl = "private"
bucket = aws_s3_bucket.main.bucket
content_language = "en-US"
content_type = "application/x-directory"
force_destroy = true
key = "log/"
}
3 changes: 3 additions & 0 deletions local.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
locals {
organization = lower(random_pet.organization.id)
}
3 changes: 3 additions & 0 deletions provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "aws" {
region = var.aws_region
}
3 changes: 3 additions & 0 deletions random_pet.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "random_pet" "organization" {
length = var.random_pet
}
11 changes: 11 additions & 0 deletions variable.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
variable "aws_region" {
default = "us-east-1"
description = "The AWS region for the hosted infrastructure."
type = string
}

variable "random_pet" {
default = 1
description = "The amount of names to be used as unique identifiers."
type = number
}
Loading