terraform-provider-nsxt icon indicating copy to clipboard operation
terraform-provider-nsxt copied to clipboard

Create NSX policy group with variable

Open thenoob999 opened this issue 3 years ago • 1 comments

Hello,

I try to execute : terraform apply -var mygroup="SecurityGroupSNS"

I have the following error:

│ Error: Invalid resource name │ │ on main.tf line 40, in resource "nsxt_policy_group" "${ ... }": │ 40: resource "nsxt_policy_group" "${var.mygroup}" { │ │ A name must start with a letter or underscore and may contain only letters, digits, underscores, and dashes.

I use this syntax: resource "nsxt_policy_group" "${var.mygroup}" { display_name = "${var.mygroup}" description = "Terraform provisioned Group" criteria { condition { key = "Tag" member_type = "VirtualMachine" operator = "EQUALS" value = "SecurityGroup|${varmygroup}" } } }

In the documentation the example is : resource "nsxt_policy_group" "group1" {

But is it not possible to use this because when I execute with a nex parameter for mygroup, terraform try to modify the "group1" while the name is not the same, the ports are not the same etc..

On others providers you have for example a "name" parameter which permit for a group to be unique and be used in "variable"

Thanks for your help Best Regards

thenoob999 avatar Oct 27 '21 13:10 thenoob999

Hello, the provider has no say in resource definition syntax - this is part of terraform core. I'm not aware of syntax that allows to use variable as resource name. I'm also not sure I understand your use case - could you please clarify why changing of terraform resource name is required?

annakhm avatar Nov 02 '21 04:11 annakhm

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

github-actions[bot] avatar Oct 28 '22 17:10 github-actions[bot]