Skip to content

Commit

Permalink
Update memory_size to GB for compute_flavors (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
niuzhenguo authored Oct 31, 2020
1 parent 2c04b01 commit 5db4cc1
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 25 deletions.
9 changes: 5 additions & 4 deletions docs/data-sources/compute_flavors.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ Use this data source to get the ID of the available Compute Flavors.

```hcl
data "huaweicloud_compute_flavors" "flavors" {
performance_type = "normal"
cpu_core_count = 2
memory_size = 4096
availability_zone = "cn-north-4a"
performance_type = "normal"
cpu_core_count = 2
memory_size = 4
}
# Create ECS instance with the first matched flavor
Expand All @@ -34,7 +35,7 @@ resource "huaweicloud_compute_instance" "instance" {

* `cpu_core_count` - (Optional) Specifies the number of vCPUs in the ECS flavor.

* `memory_size` - (Optional) Specifies the memory size(MB) in the ECS flavor.
* `memory_size` - (Optional) Specifies the memory size(GB) in the ECS flavor.


## Attributes Reference
Expand Down
7 changes: 4 additions & 3 deletions docs/resources/compute_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ This is an alternative to `huaweicloud_compute_instance_v2`
data "huaweicloud_availability_zones" "myaz" {}
data "huaweicloud_compute_flavors" "myflavor" {
performance_type = "normal"
cpu_core_count = 2
memory_size = 4096
availability_zone = data.huaweicloud_availability_zones.myaz.names[0]
performance_type = "normal"
cpu_core_count = 2
memory_size = 4
}
data "huaweicloud_vpc_subnet" "mynet" {
Expand Down
7 changes: 4 additions & 3 deletions examples/ecs/associated-eip/main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
data "huaweicloud_availability_zones" "myaz" {}

data "huaweicloud_compute_flavors" "myflavor" {
performance_type = "normal"
cpu_core_count = 2
memory_size = 4096
availability_zone = data.huaweicloud_availability_zones.myaz.names[0]
performance_type = "normal"
cpu_core_count = 2
memory_size = 4
}

data "huaweicloud_vpc_subnet" "mynet" {
Expand Down
7 changes: 4 additions & 3 deletions examples/ecs/attached-interface/main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
data "huaweicloud_availability_zones" "myaz" {}

data "huaweicloud_compute_flavors" "myflavor" {
performance_type = "normal"
cpu_core_count = 2
memory_size = 4096
availability_zone = data.huaweicloud_availability_zones.myaz.names[0]
performance_type = "normal"
cpu_core_count = 2
memory_size = 4
}

data "huaweicloud_vpc_subnet" "mynet" {
Expand Down
7 changes: 4 additions & 3 deletions examples/ecs/attached-volume/main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
data "huaweicloud_availability_zones" "myaz" {}

data "huaweicloud_compute_flavors" "myflavor" {
performance_type = "normal"
cpu_core_count = 2
memory_size = 4096
availability_zone = data.huaweicloud_availability_zones.myaz.names[0]
performance_type = "normal"
cpu_core_count = 2
memory_size = 4
}

data "huaweicloud_vpc_subnet" "mynet" {
Expand Down
7 changes: 4 additions & 3 deletions examples/ecs/basic/main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
data "huaweicloud_availability_zones" "myaz" {}

data "huaweicloud_compute_flavors" "myflavor" {
performance_type = "normal"
cpu_core_count = 2
memory_size = 4096
availability_zone = data.huaweicloud_availability_zones.myaz.names[0]
performance_type = "normal"
cpu_core_count = 2
memory_size = 4
}

data "huaweicloud_vpc_subnet" "mynet" {
Expand Down
7 changes: 4 additions & 3 deletions examples/ecs/provisioners/main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
data "huaweicloud_availability_zones" "myaz" {}

data "huaweicloud_compute_flavors" "myflavor" {
performance_type = "normal"
cpu_core_count = 2
memory_size = 4096
availability_zone = data.huaweicloud_availability_zones.myaz.names[0]
performance_type = "normal"
cpu_core_count = 2
memory_size = 4
}

data "huaweicloud_vpc_subnet" "mynet" {
Expand Down
3 changes: 2 additions & 1 deletion examples/ecs/userdata/main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
data "huaweicloud_availability_zones" "myaz" {}

data "huaweicloud_compute_flavors" "myflavor" {
availability_zone = data.huaweicloud_availability_zones.myaz.names[0]
performance_type = "normal"
cpu_core_count = 2
memory_size = 4096
memory_size = 4
}

data "huaweicloud_vpc_subnet" "mynet" {
Expand Down
2 changes: 1 addition & 1 deletion huaweicloud/data_source_huaweicloud_compute_flavors.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func dataSourceEcsFlavorsRead(d *schema.ResourceData, meta interface{}) error {
}

cpu := d.Get("cpu_core_count").(int)
mem := int64(d.Get("memory_size").(int))
mem := int64(d.Get("memory_size").(int)) * 1024
pType := d.Get("performance_type").(string)
gen := d.Get("generation").(string)
az := d.Get("availability_zone").(string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ const testAccEcsFlavorsDataSource_basic = `
data "huaweicloud_compute_flavors" "this" {
performance_type = "normal"
cpu_core_count = 2
memory_size = 4096
memory_size = 4
}
`

0 comments on commit 5db4cc1

Please sign in to comment.