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

refactor(infra): create new terraform project to prepare refactoring #1714

Merged
merged 8 commits into from
May 30, 2024
Merged
4 changes: 0 additions & 4 deletions apps/infra/deploy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,3 @@ module "codedang-infra" {
otel_port = var.otel_port

}

# module "codedang-tf-backend" {
# source = "../modules/codedang-tf-backend"
# }
82 changes: 0 additions & 82 deletions apps/infra/local/.terraform.lock.hcl

This file was deleted.

28 changes: 0 additions & 28 deletions apps/infra/local/main.tf

This file was deleted.

4 changes: 0 additions & 4 deletions apps/infra/local/provider.tf

This file was deleted.

21 changes: 0 additions & 21 deletions apps/infra/local/variable.tf

This file was deleted.

3 changes: 3 additions & 0 deletions apps/infra/projects/codedang/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Codedang

Project for Codedang
20 changes: 20 additions & 0 deletions apps/infra/projects/codedang/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~>5.0"
}
}

backend "s3" {
bucket = "codedang-tf-state"
key = "terraform/codedang.tfstate"
region = "ap-northeast-2"
encrypt = true
dynamodb_table = "terraform-state-lock"
}
}

provider "aws" {
region = var.region
}
5 changes: 5 additions & 0 deletions apps/infra/projects/codedang/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "region" {
type = string
description = "The region for provider"
default = "ap-northeast-2"
}
3 changes: 3 additions & 0 deletions apps/infra/projects/network/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Network

Project for Network
20 changes: 20 additions & 0 deletions apps/infra/projects/network/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~>5.0"
}
}

backend "s3" {
bucket = "codedang-tf-state"
key = "terraform/network.tfstate"
region = "ap-northeast-2"
encrypt = true
dynamodb_table = "terraform-state-lock"
}
}

provider "aws" {
region = var.region
}
5 changes: 5 additions & 0 deletions apps/infra/projects/network/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "region" {
type = string
description = "The region for provider"
default = "ap-northeast-2"
}
3 changes: 3 additions & 0 deletions apps/infra/projects/storage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Storage

Project for Storage
20 changes: 20 additions & 0 deletions apps/infra/projects/storage/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~>5.0"
}
}

backend "s3" {
bucket = "codedang-tf-state"
key = "terraform/storage.tfstate"
region = "ap-northeast-2"
encrypt = true
dynamodb_table = "terraform-state-lock"
}
}

provider "aws" {
region = var.region
}
5 changes: 5 additions & 0 deletions apps/infra/projects/storage/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "region" {
type = string
description = "The region for provider"
default = "ap-northeast-2"
}
37 changes: 37 additions & 0 deletions apps/infra/projects/terraform-configuration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Terraform Backend configuration

Project for Terraform Backend Configuration about where Terraform stores its state data files.

## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~>5.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~>5.0 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_dynamodb_table.tfstate](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dynamodb_table) | resource |
| [aws_s3_bucket.tfstate](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
| [aws_s3_bucket_versioning.tfstate](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_versioning) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_region"></a> [region](#input\_region) | The region for provider | `string` | `"ap-northeast-2"` | no |

## Outputs

No outputs.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# S3 bucket for Terraform Backend
resource "aws_s3_bucket" "tfstate" {
bucket = "codedang-tf-state"
}
Expand All @@ -10,7 +9,6 @@ resource "aws_s3_bucket_versioning" "tfstate" {
}
}

# # DynamoDB for Terraform State lock
resource "aws_dynamodb_table" "tfstate" {
name = "terraform-state-lock"
billing_mode = "PAY_PER_REQUEST"
Expand Down
12 changes: 12 additions & 0 deletions apps/infra/projects/terraform-configuration/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~>5.0"
}
}
}

provider "aws" {
region = var.region
}
5 changes: 5 additions & 0 deletions apps/infra/projects/terraform-configuration/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "region" {
type = string
description = "The region for provider"
default = "ap-northeast-2"
}
3 changes: 3 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ pre-commit:
glob: '*.go'
run: go fmt -n ./...
root: iris
terraformfmt:
glob: '*.tf'
run: terraform fmt {staged_files}

commit-msg:
commands:
Expand Down
Loading