Closed cybrknght closed 2 years ago
The error message returned from the API is confusing, when it says name
, it is referring to instance_type
(in your example, t2.micro
), not the flavor mapping name
(in your example, micro
).
Flavor mapping name
is a mandatory attribute, the attributes that cannot be specified together are instance_type
with cpu_count
/memory
. instance_type
should be used when mapping a public cloud instance type, and cpu_count
/memory
when mapping a private cloud like vSphere. For example:
resource "vra_flavor_profile" "aws" {
name = "tf-aws-flavor-profile"
description = "My AWS flavor"
region_id = data.vra_region.aws.id
flavor_mapping {
name = "small"
instance_type = "t2.small"
}
flavor_mapping {
name = "medium"
instance_type = "t2.medium"
}
}
resource "vra_flavor_profile" "vsphere" {
name = "tf-vsphere-flavor-profile"
description = "My vSphere flavor"
region_id = data.vra_region.vsphere.id
flavor_mapping {
name = "small"
cpu_count = 2
memory = 2048
}
flavor_mapping {
name = "medium"
cpu_count = 4
memory = 4096
}
}
At #460, I've updated the attribute descriptions, examples, and documentation to reflect this.
Code of Conduct
This project has a Code of Conduct that all participants are expected to understand and follow:
vRA Version
vRA version 8.8.1
Terraform Version
Terraform version 1.23
vRA Terraform Provider Version
vra provider version 0.5.1
Affected Resource(s)
vra_flavor_profile
Terraform Configuration Files
Expected Behavior
You should be able to specify flavor_mappings using either
name
andinstance_type
orcpu_count
andmemory
. (This is how the API '/iaas/api/flavor-profiles' works.) In addition, for this to work, you should also be able to specify the 'flavor name' along with thename
andinstance_type
orcpu_count
andmemory
. Currently, thename
and 'flavor name' are the same, which are two separate things in the API.Actual Behavior
If you specify the
name
andcpu_count
andmemory
together, you get the following error:Error: [POST /iaas/api/flavor-profiles][400] createFlavorProfileBadRequest &{Message:Invalid request: flavorMapping "medium" contains both "name" and "memoryInMB" and/or "cpuCount". Either one should be supplied but not both. StatusCode:400}
However, if you specify only
cpu_count
andmemory
, you get an error saying "Error: Missing required argument, The argument "name" is required, but no definition was found.'Steps to Reproduce
vra_flavor_profile
provider, create avra_flavor_profile
with aflavor_mapping
that only containscpu_count
andmemory
, instead ofname
terraform apply
Community Note