提交 fdcd204e 编写于 作者: I imjoey

Format tf config files to a cannonical format

Signed-off-by: Nimjoey <majunjiev@gmail.com>
上级 4184ca2d
resource "huaweicloud_cce_cluster_v3" "this" {
name = "${var.name}"
cluster_type= "VirtualMachine"
flavor_id= "${var.flavor_id}"
vpc_id= "${var.vpc_id}"
subnet_id= "${var.subnet_id}"
container_network_type= "overlay_l2"
authentication_mode = "rbac"
description= "${var.description}"
name = "${var.name}"
cluster_type = "VirtualMachine"
flavor_id = "${var.flavor_id}"
vpc_id = "${var.vpc_id}"
subnet_id = "${var.subnet_id}"
container_network_type = "overlay_l2"
authentication_mode = "rbac"
description = "${var.description}"
}
resource "huaweicloud_cce_node_v3" "this" {
count = "${length(var.nodes)}"
cluster_id= "${join("",huaweicloud_cce_cluster_v3.this.*.id)}"
name = "${lookup(var.nodes[count.index], "name")}"
flavor_id="${lookup(var.nodes[count.index], "flavor_id")}"
iptype="5_bgp"
availability_zone= "${lookup(var.nodes[count.index], "az")}"
key_pair="${lookup(var.nodes[count.index], "ssh_key")}"
root_volume {
size= 40
volumetype= "SATA"
}
sharetype= "PER"
bandwidth_size= 100
data_volumes {
size= 100
volumetype= "SATA"
}
count = "${length(var.nodes)}"
cluster_id = "${join("", huaweicloud_cce_cluster_v3.this.*.id)}"
name = "${lookup(var.nodes[count.index], "name")}"
flavor_id = "${lookup(var.nodes[count.index], "flavor_id")}"
iptype = "5_bgp"
availability_zone = "${lookup(var.nodes[count.index], "az")}"
key_pair = "${lookup(var.nodes[count.index], "ssh_key")}"
root_volume {
size = 40
volumetype = "SATA"
}
sharetype = "PER"
bandwidth_size = 100
data_volumes {
size = 100
volumetype = "SATA"
}
}
output "clusters_1" {
description = "The first cluster information"
value = "${
value = "${
map(
"name", "${huaweicloud_cce_cluster_v3.this.certificate_clusters.0.name}",
"server", "${huaweicloud_cce_cluster_v3.this.certificate_clusters.0.server}",
"certificate_authority", "${huaweicloud_cce_cluster_v3.this.certificate_clusters.0.certificate_authority_data}"
"certificate_authority", "${huaweicloud_cce_cluster_v3.this.certificate_clusters.0.certificate_authority_data}"
)
}"
}
output "users_1" {
description = "List first user infomation"
value = "${
value = "${
map(
"name", "${huaweicloud_cce_cluster_v3.this.certificate_users.0.name}",
"client_certificate", "${huaweicloud_cce_cluster_v3.this.certificate_users.0.client_certificate_data}",
"client_key", "${huaweicloud_cce_cluster_v3.this.certificate_users.0.client_key_data}"
"client_key", "${huaweicloud_cce_cluster_v3.this.certificate_users.0.client_key_data}"
)
}"
}
......@@ -23,11 +23,11 @@ output "users_1" {
output "clusters" {
description = "List the clusters"
value = "${huaweicloud_cce_cluster_v3.this.certificate_clusters}"
value = "${huaweicloud_cce_cluster_v3.this.certificate_clusters}"
}
output "users" {
description = "List the users information"
value = "${huaweicloud_cce_cluster_v3.this.certificate_users}"
value = "${huaweicloud_cce_cluster_v3.this.certificate_users}"
}
......@@ -28,7 +28,7 @@ variable "subnet_id" {
}
variable "nodes" {
type = list(map(string))
type = list(map(string))
description = "List of cluster node"
default = []
}
resource "huaweicloud_dns_ptrrecord_v2" "this" {
count = "${length(var.ptrs)}"
name = "${lookup(var.ptrs[count.index], "domain", null)}"
description = "${lookup(var.ptrs[count.index], "description", "ptr")}"
count = "${length(var.ptrs)}"
name = "${lookup(var.ptrs[count.index], "domain", null)}"
description = "${lookup(var.ptrs[count.index], "description", "ptr")}"
floatingip_id = "${lookup(var.ptrs[count.index], "ip", null)}"
ttl = "${lookup(var.ptrs[count.index], "ttl", 3000)}"
ttl = "${lookup(var.ptrs[count.index], "ttl", 3000)}"
}
......
......@@ -8,27 +8,27 @@ variable "email" {
variable "ttl" {
description = "The ttl time"
default = 3000
}
default = 3000
}
variable "type" {
description = "The DNS type, the value would be public or private"
default = "public"
default = "public"
}
variable "description" {
description = "The dns description string"
default = ""
default = ""
}
variable "records" {
type = list(map(string))
type = list(map(string))
description = "List of each dns records"
default = []
default = []
}
variable "ptrs" {
type = list(map(string))
type = list(map(string))
description = "List of ptr records"
default = []
}
......@@ -7,7 +7,7 @@ resource "huaweicloud_lb_loadbalancer_v2" "this" {
}
resource "huaweicloud_networking_floatingip_associate_v2" "this" {
count = "${length(var.loadbalancers)}"
count = "${length(var.loadbalancers)}"
floating_ip = "${lookup(var.loadbalancers[count.index], "eip", null)}"
port_id = "${huaweicloud_lb_loadbalancer_v2.this[count.index].vip_port_id}"
}
output "this_elb_ids" {
description = "List of IDs of the elbs"
value = "${join(",",huaweicloud_lb_loadbalancer_v2.this.*.id)}"
value = "${join(",", huaweicloud_lb_loadbalancer_v2.this.*.id)}"
}
output "this_port_ids" {
description = "List of the port ids of all elbs"
value = "${join(",",huaweicloud_lb_loadbalancer_v2.this.*.vip_port_id)}"
value = "${join(",", huaweicloud_lb_loadbalancer_v2.this.*.vip_port_id)}"
}
variable "loadbalancers" {
type = list(map(string))
type = list(map(string))
description = "List of load banlancers"
default = []
}
resource "huaweicloud_vpc_eip_v1" "this" {
count = "${length(var.eips)}"
count = "${length(var.eips)}"
publicip {
type = "5_bgp"
}
bandwidth {
id = "${lookup(var.eips[count.index], "bandwidth_id", null)}"
id = "${lookup(var.eips[count.index], "bandwidth_id", null)}"
share_type = "WHOLE"
}
}
resource "huaweicloud_vpc_bandwidth_v2" "this" {
count = "${length(var.bandwidths)}"
name = "${lookup(var.bandwidths[count.index], "name", null)}"
size = "${lookup(var.bandwidths[count.index], "size", 5)}"
count = "${length(var.bandwidths)}"
name = "${lookup(var.bandwidths[count.index], "name", null)}"
size = "${lookup(var.bandwidths[count.index], "size", 5)}"
}
variable "eips" {
type = list(map(string))
type = list(map(string))
description = "List of eips"
default = []
}
variable "bandwidths" {
type = list(map(string))
type = list(map(string))
description = "List of bandwidths"
default = []
default = []
}
output "this_eip_ids" {
description = "List of IDs of the eips"
value = "${join(",",huaweicloud_vpc_eip_v1.this.*.id)}"
value = "${join(",", huaweicloud_vpc_eip_v1.this.*.id)}"
}
output "this_eip_addresses" {
description = "List of address of the eips"
value = "${join(",",huaweicloud_vpc_eip_v1.this.*.publicip.0.ip_address)}"
value = "${join(",", huaweicloud_vpc_eip_v1.this.*.publicip.0.ip_address)}"
}
output "this_bandwidth_ids" {
description = "List of bandwidth ids"
value = "${join(",",huaweicloud_vpc_bandwidth_v2.this.*.id)}"
value = "${join(",", huaweicloud_vpc_bandwidth_v2.this.*.id)}"
}
......@@ -10,7 +10,7 @@ resource "huaweicloud_nat_snat_rule_v2" "this" {
count = "${length(var.rules)}"
nat_gateway_id = "${huaweicloud_nat_gateway_v2.this.id}"
network_id = "${lookup(var.rules[count.index], "network_id", null)}"
floating_ip_id = "${lookup(var.rules[count.index],"eip_id",null)}"
floating_ip_id = "${lookup(var.rules[count.index], "eip_id", null)}"
}
......@@ -22,7 +22,7 @@ variable "network_id" {
}
variable "rules" {
type = list(map(string))
type = list(map(string))
description = "List of rules in the nat"
default = []
}
output "this_vpc_id" {
description = "The ID of the VPC"
value = "${var.vpc_id=="" ? join("",huaweicloud_vpc_v1.this.*.id) : var.vpc_id}"
value = "${var.vpc_id == "" ? join("", huaweicloud_vpc_v1.this.*.id) : var.vpc_id}"
}
output "this_subnet_ids" {
description = "List of IDs of the Subnets"
value = "${join(",",huaweicloud_vpc_subnet_v1.this.*.subnet_id)}"
value = "${join(",", huaweicloud_vpc_subnet_v1.this.*.subnet_id)}"
}
output "this_network_ids" {
description = "List of Network IDs of the Subnets"
value = "${join(",",huaweicloud_vpc_subnet_v1.this.*.id)}"
value = "${join(",", huaweicloud_vpc_subnet_v1.this.*.id)}"
}
# Create VPC
resource "huaweicloud_vpc_v1" "this" {
count = "${var.vpc_id=="" ? 1 : 0}"
count = "${var.vpc_id == "" ? 1 : 0}"
name = "${var.name}"
cidr = "${var.cidr}"
}
......@@ -14,5 +14,5 @@ resource "huaweicloud_vpc_subnet_v1" "this" {
availability_zone = "${lookup(var.subnets[count.index], "availability_zone", null)}"
primary_dns = "${lookup(var.subnets[count.index], "primary_dns", null)}"
secondary_dns = "${lookup(var.subnets[count.index], "secondary_dns", null)}"
vpc_id = "${var.vpc_id=="" ? join("",huaweicloud_vpc_v1.this.*.id) : var.vpc_id}"
vpc_id = "${var.vpc_id == "" ? join("", huaweicloud_vpc_v1.this.*.id) : var.vpc_id}"
}
......@@ -14,7 +14,7 @@ variable "cidr" {
}
variable "subnets" {
type = list(map(string))
type = list(map(string))
description = "List of subnets in the VPC"
default = []
}
output "cce_clusters" {
value = "${module.cce.clusters}"
value = "${module.cce.clusters}"
}
output "cce_users" {
value = "${module.cce.users}"
value = "${module.cce.users}"
}
output "exim4_elb_id" {
value = "${length(split(",", module.elb.this_elb_ids)) > 1 ? split(",", module.elb.this_elb_ids)[1] : null}"
value = "${length(split(",", module.elb.this_elb_ids)) > 1 ? split(",", module.elb.this_elb_ids)[1] : null}"
}
output "web_elb_id" {
value = "${length(split(",", module.elb.this_elb_ids)) > 0 ? split(",", module.elb.this_elb_ids)[0] : null}"
output "web_elb_id" {
value = "${length(split(",", module.elb.this_elb_ids)) > 0 ? split(",", module.elb.this_elb_ids)[0] : null}"
}
output "exim4_eip" {
value = "${length(split(",", module.internet.this_eip_addresses)) > 1? split(",", module.internet.this_eip_addresses)[2] : null}"
value = "${length(split(",", module.internet.this_eip_addresses)) > 1 ? split(",", module.internet.this_eip_addresses)[2] : null}"
}
output "web_eip" {
value = "${length(split(",", module.internet.this_eip_addresses)) > 0 ? split(",", module.internet.this_eip_addresses)[1] : null}"
value = "${length(split(",", module.internet.this_eip_addresses)) > 0 ? split(",", module.internet.this_eip_addresses)[1] : null}"
}
output "exim4_domain" {
value = "${var.sub_domain_mail}.${var.domain}"
value = "${var.sub_domain_mail}.${var.domain}"
}
output "web_domain" {
value = "${var.sub_domain_web}.${var.domain}"
value = "${var.sub_domain_web}.${var.domain}"
}
output "dkim_selector" {
value = "${var.selector}"
value = "${var.selector}"
}
module "network" {
source ="./network/"
source = "./network/"
// VPC
name = "net-community"
......@@ -18,38 +18,38 @@ module "network" {
module "cce" {
source = "./cce"
name = "cce-community"
name = "cce-community"
description = "This is cce cluster for community"
vpc_id = "${module.network.this_vpc_id}"
subnet_id = "${split(",", module.network.this_network_ids)[0]}"
flavor_id = "cce.s1.large"
vpc_id = "${module.network.this_vpc_id}"
subnet_id = "${split(",", module.network.this_network_ids)[0]}"
flavor_id = "cce.s1.large"
nodes = [
{
name = "node1",
ssh_key = "${var.keypair}",
az = "${var.az}",
name = "node1",
ssh_key = "${var.keypair}",
az = "${var.az}",
flavor_id = "${var.node_flavor}"
},
{
name = "node1",
ssh_key = "${var.keypair}",
az = "${var.az}",
name = "node1",
ssh_key = "${var.keypair}",
az = "${var.az}",
flavor_id = "${var.node_flavor}"
},
{
name = "node1",
ssh_key = "${var.keypair}",
az = "${var.az}",
name = "node1",
ssh_key = "${var.keypair}",
az = "${var.az}",
flavor_id = "${var.node_flavor}"
}
]
]
}
module "internet" {
source = "./internet"
bandwidths = [
{
name = "bandwidth-mail"
......@@ -59,8 +59,8 @@ module "internet" {
name = "bandwidth-website"
size = "30"
}
]
]
eips = [
{
bandwidth_id = "${split(",", module.internet.this_bandwidth_ids)[0]}"
......@@ -73,23 +73,23 @@ module "internet" {
},
{
bandwidth_id = "${split(",", module.internet.this_bandwidth_ids)[1]}"
}
}
]
}
module "nat" {
source = "./nat"
name = "nat-community"
name = "nat-community"
description = "this is a nat gateway to provide the access to internet for node"
spec_code = 3
router_id = "${module.network.this_vpc_id}"
network_id = "${split(",", module.network.this_network_ids)[0]}"
spec_code = 3
router_id = "${module.network.this_vpc_id}"
network_id = "${split(",", module.network.this_network_ids)[0]}"
rules = [
{
network_id = "${split(",", module.network.this_network_ids)[0]}"
eip_id = "${split(",",module.internet.this_eip_ids)[0]}"
eip_id = "${split(",", module.internet.this_eip_ids)[0]}"
}
]
}
......@@ -97,78 +97,78 @@ module "nat" {
module "elb" {
source = "./elb"
loadbalancers = [
{
name = "elb-web"
name = "elb-web"
description = "The load balancer of mailman-web"
subnet_id = "${split(",", module.network.this_subnet_ids)[0]}"
eip = "${split(",", module.internet.this_eip_addresses)[1]}"
subnet_id = "${split(",", module.network.this_subnet_ids)[0]}"
eip = "${split(",", module.internet.this_eip_addresses)[1]}"
},
{
name = "elb-mta"
name = "elb-mta"
description = "The load balancer of mail MTA"
subnet_id = "${split(",", module.network.this_subnet_ids)[0]}"
eip = "${split(",", module.internet.this_eip_addresses)[2]}"
subnet_id = "${split(",", module.network.this_subnet_ids)[0]}"
eip = "${split(",", module.internet.this_eip_addresses)[2]}"
},
{
name = "elb-website"
name = "elb-website"
description = "The load balancer of website"
subnet_id = "${split(",", module.network.this_subnet_ids)[0]}"
eip = "${split(",", module.internet.this_eip_addresses)[3]}"
subnet_id = "${split(",", module.network.this_subnet_ids)[0]}"
eip = "${split(",", module.internet.this_eip_addresses)[3]}"
},
]
}
module "dns" {
source = "./dns"
domain = "${var.domain}."
email = "${var.email}"
records = [
{
domain = "${var.domain}."
type = "A"
value = "${split(",", module.internet.this_eip_addresses)[3]}"
type = "A"
value = "${split(",", module.internet.this_eip_addresses)[3]}"
},
{
domain = "${var.sub_domain_mail}.${var.domain}."
type = "A"
value = "${split(",", module.internet.this_eip_addresses)[2]}"
type = "A"
value = "${split(",", module.internet.this_eip_addresses)[2]}"
},
{
domain = "${var.sub_domain_web}.${var.domain}."
type = "A"
value = "${split(",", module.internet.this_eip_addresses)[1]}"
type = "A"
value = "${split(",", module.internet.this_eip_addresses)[1]}"
},
{
domain = "${var.domain}."
type = "MX"
value = "1 ${var.sub_domain_mail}.${var.domain}."
type = "MX"
value = "1 ${var.sub_domain_mail}.${var.domain}."
},
{
domain = "${var.domain}."
type = "TXT"
value = "\"v=spf1 a mx ip4:${split(",", module.internet.this_eip_addresses)[0]} ~all\""
type = "TXT"
value = "\"v=spf1 a mx ip4:${split(",", module.internet.this_eip_addresses)[0]} ~all\""
},
{
domain = "_dmarc.${var.domain}."
type = "TXT"
value = "\"v=DMARC1;p=reject;sp=reject;adkim=r;aspf=r;fo=1;rf=afrf;pct=100;ruf=mailto:${var.email};ri=86400\""
type = "TXT"
value = "\"v=DMARC1;p=reject;sp=reject;adkim=r;aspf=r;fo=1;rf=afrf;pct=100;ruf=mailto:${var.email};ri=86400\""
},
{
domain = "${var.selector}._domainkey.${var.domain}."
type = "TXT"
value = "\"v=DKIM1;k=rsa;p=${var.dkim_public_key}\""
type = "TXT"
value = "\"v=DKIM1;k=rsa;p=${var.dkim_public_key}\""
}
]
ptrs = [
{
domain = "${var.domain}."
ip = "${split(",", module.internet.this_eip_ids)[0]}"
domain = "${var.domain}."
ip = "${split(",", module.internet.this_eip_ids)[0]}"
}
]
}
}
output "this_security_group_id" {
description = "The ID of the security group"
value = "${var.security_group_id=="" ? join("",huaweicloud_networking_secgroup_v2.this.*.id) : var.security_group_id}"
description = "The ID of the security group"
value = "${var.security_group_id == "" ? join("", huaweicloud_networking_secgroup_v2.this.*.id) : var.security_group_id}"
}
# Create Security Group
resource "huaweicloud_networking_secgroup_v2" "this" {
count = "${var.security_group_id=="" ? 1 : 0}"
count = "${var.security_group_id == "" ? 1 : 0}"
name = "${var.name}"
description = "${var.description}"
delete_default_rules = "${var.delete_default_rules}"
......@@ -8,12 +8,12 @@ resource "huaweicloud_networking_secgroup_v2" "this" {
# Create Security Group Rule
resource "huaweicloud_networking_secgroup_rule_v2" "this" {
count = "${length(var.rules)}"
count = "${length(var.rules)}"
direction = "${lookup(var.rules[count.index], "direction")}"
ethertype = "${lookup(var.rules[count.index], "ethertype")}"
protocol = "${lookup(var.rules[count.index], "protocol")}"
port_range_min = "${lookup(var.rules[count.index], "port_range_min")}"
port_range_max = "${lookup(var.rules[count.index], "port_range_max")}"
remote_ip_prefix = "${lookup(var.rules[count.index], "remote_ip_cidr")}"
security_group_id = "${var.security_group_id=="" ? join("",huaweicloud_networking_secgroup_v2.this.*.id) : var.security_group_id}"
security_group_id = "${var.security_group_id == "" ? join("", huaweicloud_networking_secgroup_v2.this.*.id) : var.security_group_id}"
}
......@@ -20,7 +20,7 @@ variable "delete_default_rules" {
}
variable "rules" {
type = list(map(string))
type = list(map(string))
description = "List of rules in a security group"
default = []
}
#Required vars
variable "domain" {
description = "The email domain that will be served on. e.g. example.com"
default = "openeuler.org"
description = "The email domain that will be served on. e.g. example.com"
default = "openeuler.org"
}
variable "email" {
description = "The admin email of dns domain. e.g. example@gmail.com"
default = "freesky.edward@gmail.com"
description = "The admin email of dns domain. e.g. example@gmail.com"
default = "freesky.edward@gmail.com"
}
variable "dkim_public_key" {
description = "The DKIM public key, must be rsa more than 1024, 2048 should be plus"
description = "The DKIM public key, must be rsa more than 1024, 2048 should be plus"
}
#
......@@ -19,32 +19,32 @@ variable "dkim_public_key" {
## The cluster vars
variable "keypair" {
description = "The key pair for cce cluster node login."
default = "KeyPair-infra"
description = "The key pair for cce cluster node login."
default = "KeyPair-infra"
}
variable "az" {
description = "The AZ that system will run on"
default = "ap-southeast-1a"
description = "The AZ that system will run on"
default = "ap-southeast-1a"
}
variable "node_flavor" {
description = "The default flavor of cce node"
default = "s3.xlarge.4"
description = "The default flavor of cce node"
default = "s3.xlarge.4"
}
## The dns configuation vars
variable "selector" {
description = "The DKIM hander name"
default = "20191010"
description = "The DKIM hander name"
default = "20191010"
}
variable "sub_domain_mail" {
description = "The sub domain that exim4 will serve on"
default = "mail"
description = "The sub domain that exim4 will serve on"
default = "mail"
}
variable "sub_domain_web" {
description = "The sub domain that mailman web will serve on"
default = "mailweb"
description = "The sub domain that mailman web will serve on"
default = "mailweb"
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册