-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from yunkon-kim/241104-19
Add NCP MongoDB and Object Storage examples
- Loading branch information
Showing
6 changed files
with
187 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
terraform { | ||
|
||
# Required Tofu version | ||
required_version = "~>1.8.3" | ||
|
||
required_providers { | ||
ncloud = { | ||
source = "NaverCloudPlatform/ncloud" | ||
version = "3.2.1" | ||
} | ||
} | ||
} | ||
|
||
provider "ncloud" { | ||
access_key = var.ncloud_access_key | ||
secret_key = var.ncloud_secret_key | ||
region = "KR" # Set the desired region (e.g., "KR", "JP", etc.) | ||
support_vpc = true # Enable VPC support | ||
} | ||
|
||
# Declare variables | ||
variable "ncloud_access_key" { | ||
description = "Naver Cloud Platform Access Key" | ||
type = string | ||
default = "" # Leave the default value empty | ||
} | ||
|
||
variable "ncloud_secret_key" { | ||
description = "Naver Cloud Platform Secret Key" | ||
type = string | ||
default = "" # Leave the default value empty | ||
} | ||
|
||
# Declare MongoDB admin user | ||
variable "mongodb_user_name" { | ||
description = "MongoDB admin username" | ||
type = string | ||
default = "dbadmin" # 기본 관리자 사용자명 | ||
} | ||
|
||
# Declare MongoDB admin password | ||
variable "mongodb_user_password" { | ||
description = "MongoDB admin password" | ||
type = string | ||
sensitive = true # 민감 정보로 표시 | ||
default = "P@ssw0rd!" # 기본 관리자 비밀번호 | ||
} | ||
|
||
# Create VPC | ||
resource "ncloud_vpc" "example" { | ||
name = "tofu-vpc-mongodb" | ||
ipv4_cidr_block = "10.0.0.0/16" # CIDR block for the VPC | ||
} | ||
|
||
# Create Network ACL | ||
resource "ncloud_network_acl" "nacl" { | ||
vpc_no = ncloud_vpc.example.id | ||
} | ||
|
||
# Create Subnet | ||
resource "ncloud_subnet" "example" { | ||
name = "tofu-subnet-mongodb" | ||
vpc_no = ncloud_vpc.example.vpc_no | ||
subnet = cidrsubnet(ncloud_vpc.example.ipv4_cidr_block, 8, 0) # "10.0.0.0/24" CIDR block for the subnet | ||
zone = "KR-1" # Availability zone | ||
network_acl_no = ncloud_vpc.example.default_network_acl_no # Network ACL number | ||
subnet_type = "PUBLIC" # Subnet type | ||
} | ||
|
||
# Create MongoDB instance | ||
resource "ncloud_mongodb" "mongodb" { | ||
vpc_no = ncloud_vpc.example.id | ||
subnet_no = ncloud_subnet.example.id | ||
service_name = "tofu-mongodb" | ||
server_name_prefix = "tf-svr" | ||
user_name = var.mongodb_user_name # Admin username (variable used) | ||
user_password = var.mongodb_user_password # Admin password (variable used) | ||
cluster_type_code = "STAND_ALONE" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
output "mongodbInfo" { | ||
description = "Information MongoDB instance" | ||
value = { | ||
service_name = ncloud_mongodb.mongodb.service_name | ||
instance_id = ncloud_mongodb.mongodb.id | ||
cluster_type = ncloud_mongodb.mongodb.cluster_type_code | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
terraform { | ||
|
||
# Required Tofu version | ||
required_version = "~>1.8.3" | ||
|
||
required_providers { | ||
ncloud = { | ||
source = "NaverCloudPlatform/ncloud" | ||
version = "3.2.1" | ||
} | ||
} | ||
} | ||
|
||
provider "ncloud" { | ||
access_key = var.ncloud_access_key | ||
secret_key = var.ncloud_secret_key | ||
region = "KR" # Set the desired region (e.g., "KR", "JP", etc.) | ||
support_vpc = true # Enable VPC support | ||
} | ||
|
||
# Declare variables | ||
variable "ncloud_access_key" { | ||
description = "Naver Cloud Platform Access Key" | ||
type = string | ||
default = "" # Leave the default value empty | ||
} | ||
|
||
variable "ncloud_secret_key" { | ||
description = "Naver Cloud Platform Secret Key" | ||
type = string | ||
default = "" # Leave the default value empty | ||
} | ||
|
||
# Create object storage bucket | ||
resource "ncloud_objectstorage_bucket" "tofu_bucket" { | ||
bucket_name = "tofu-bucket" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
output "ObjectStorageInfo" { | ||
description = "Naver Cloud Platform Object Storage Bucket Information" | ||
value = { | ||
bucket_name = ncloud_objectstorage_bucket.tofu_bucket.bucket_name | ||
creation_date = ncloud_objectstorage_bucket.tofu_bucket.creation_date | ||
bucket_id = ncloud_objectstorage_bucket.tofu_bucket.id | ||
} | ||
} |