Infra

Terraform으로 NCP 구축하기(4) - Object Storage 구성하기

SungHoJung 2025. 5. 8. 18:10

Object Storage 관련 모듈을 따로 storage_module로 관리하기 때문에, 폴더 안에 porvider 정보를 작성해준다.

# storage_module/providers.tf

terraform {
  required_providers {
    ncloud = {
      source  = "NaverCloudPlatform/ncloud"
      version = ">= 3.3.1"
    }
  }
}

버킷 정보를 작성해준다

# storage_module/bucket.tf

resource "ncloud_objectstorage_bucket" "bucket" {
  bucket_name = var.bucket_name
}

추후 다른 모듈에 넘겨줄 일을 위해서 outputs.tf를 작성한다.

# storage_module/outputs.tf

output "bucket_name" {
  description = "생성된 버킷 이름"
  value       = ncloud_objectstorage_bucket.bucket.bucket_name
}

해당 모듈에서 사용할 변수를 정의한다

# storage_module/variables.tf

variable "bucket_name" {
  description = "생성할 Object Storage 버킷 이름"
  default     = "tf-ncp-storage"
}