Skip to content

Commit

Permalink
update structure to use organization folder
Browse files Browse the repository at this point in the history
  • Loading branch information
msambartolomeo committed May 19, 2023
1 parent db925d9 commit 3fb7a0e
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 87 deletions.
70 changes: 0 additions & 70 deletions terraform/main.tf

This file was deleted.

7 changes: 7 additions & 0 deletions terraform/organization/apigateway.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module "apigateway" {
source = "../modules/apigw"

name = local.apigateway.name
template_file = local.apigateway.template_file
stage_name = local.apigateway.stage_name
}
9 changes: 9 additions & 0 deletions terraform/organization/cloudfront.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module "cloudfront" {
source = "../modules/cdn"

bucket_regional_domain_name = module.s3["website"].bucket_regional_domain_name
bucket_name = module.s3["website"].bucket_id
apigw_invoke_url = module.apigateway.invoke_url
apigw_base_path = local.apigateway.base_path
apigw_stage = "/${local.apigateway.stage_name}"
}
23 changes: 23 additions & 0 deletions terraform/organization/dynamodb.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module "dynamodb" {
for_each = local.dynamodb.tables
source = "terraform-aws-modules/dynamodb-table/aws"

name = each.value.name
hash_key = "pk"
range_key = "sk"

billing_mode = "PROVISIONED"
read_capacity = var.dynamodb_read_capacity
write_capacity = var.dynamodb_write_capacity

attributes = [
{
name = "pk"
type = "S"
},
{
name = "sk"
type = "S"
}
]
}
9 changes: 9 additions & 0 deletions terraform/organization/lambda.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module "lambda" {
source = "../modules/lambda"

lambdas = local.lambdas
vpc_id = module.vpc.id
subnet_ids = [for s in module.vpc.subnets : s.id]
apigw_execution_arn = module.apigateway.execution_arn
vpc_endpoints = module.vpc.vpc_endpoints
}
24 changes: 12 additions & 12 deletions terraform/locals.tf → terraform/organization/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ locals {
lambdas = {
lambda = {
name = "lambda"
path = "./resources/lambda/lambda.zip"
hash = filebase64sha256("./resources/lambda/lambda.zip")
path = "../resources/lambda/lambda.zip"
hash = filebase64sha256("../resources/lambda/lambda.zip")
handler = "lambda.handler"
runtime = "python3.9"
},
getUser = {
name = "getUser"
path = "./resources/lambda/getUser.zip"
hash = filebase64sha256("./resources/lambda/getUser.zip")
path = "../resources/lambda/getUser.zip"
hash = filebase64sha256("../resources/lambda/getUser.zip")
handler = "getUser.handler"
runtime = "python3.9"
}
getHistory = {
name = "getHistory"
path = "./resources/lambda/getHistory.zip"
hash = filebase64sha256("./resources/lambda/getHistory.zip")
path = "../resources/lambda/getHistory.zip"
hash = filebase64sha256("../resources/lambda/getHistory.zip")
handler = "getHistory.handler"
runtime = "python3.9"
environment = {
Expand Down Expand Up @@ -110,10 +110,10 @@ locals {
bucket_name = "cloud-website"
encription_algorithm = "AES256"
objects = [
for file in fileset("./resources/html/", "**/*.html") : {
for file in fileset("../resources/html/", "**/*.html") : {
key = file
source = "./resources/html/${file}"
etag = filemd5("./resources/html/${file}")
source = "../resources/html/${file}"
etag = filemd5("../resources/html/${file}")
content_type = "text/html"
}
]
Expand All @@ -127,10 +127,10 @@ locals {
encription_algorithm = "AES256"
# NOTE: Example record for testing
objects = [
for file in fileset("./resources/medical-records/", "**/*.pdf") : {
for file in fileset("../resources/medical-records/", "**/*.pdf") : {
key = file
source = "./resources/medical-records/${file}"
etag = filemd5("./resources/medical-records/${file}")
source = "../resources/medical-records/${file}"
etag = filemd5("../resources/medical-records/${file}")
content_type = "application/pdf"
}
]
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions terraform/organization/s3.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module "s3" {
for_each = local.s3
source = "../modules/s3"

access_ids = [module.cloudfront.OAI]
bucket_name = each.value.bucket_name
objects = each.value.objects
website_configuration = try(each.value.website_configuration, {})
encription_algorithm = each.value.encription_algorithm
}
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions terraform/organization/vpc.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module "vpc" {
source = "../modules/vpc"

name = local.vpc.name
cidr_block = local.vpc.cidr_block
vpc_endpoints = local.vpc.endpoints
}
5 changes: 0 additions & 5 deletions terraform/terraform.example.tfvars

This file was deleted.

0 comments on commit 3fb7a0e

Please sign in to comment.