Forum Discussion
AS3 pool members using a list
I have started to play with AS3. I've tried some examples and they work fine.
But I have counter a problem. Maybe it is not possible.
I am using Terraform and AS3 data template to configure a virtual server.
data template_file "init" {
template = file("example.tpl")
vars = {
TENANT = var.TENANT
VIP = var.VIP
POOL = var.POOL
LB_MODE = var.LB_MODE
MONITOR = var.MONITOR
MEMBERS = jsonencode(var.MEMBERS)
}
}
resource "bigip_as3" "as3-deploy-tenant" {
as3_json = data.template_file.init.rendered
}
MEMBERS is a list :
variable "MEMBERS" {
type = list(string)
default = []
}
MEMBERS = ["1.1.1.1","9.9.9.9"]
I am using jsonencode() function as it seems this is used for lists in Terraform.
It seemed it did not work. I get this:
Planning failed. Terraform encountered an error while generating this plan.
╷
│ Error: "as3_json" contains an invalid JSON: invalid character '1' after array element
│
│ with bigip_as3.as3-deploy-tenant,
│ on main.tf line 25, in resource "bigip_as3" "as3-deploy-tenant":
│ 25: resource "bigip_as3" "as3-deploy-tenant" {
It works if MEMBERS is just a string variable. Or if I choose just the first element of the list for example without the jsonencode function.
But I was wondering if I could use a list because I ma trying to do this in my template file:
"${POOL}": {
"class": "Pool",
"loadBalancingMode":"${LB_MODE}",
"monitors": [
"${MONITOR}"
],
"members": [
{
"servicePort": 80,
"serverAddresses": [
"${MEMBERS}"
]
}
]
}
Thanks in advance for any hint you might have.
Try removing the square brackets and quotes around the ${MEMBERS} variable in the JSON. I spotted this example from one of Sebastian_Maniak 's guides:
in the module: MY_POOLMEMBERS = jsonencode(var.pool_members) in the json: "members": [{ "servicePort": 80, "shareNodes": true, "serverAddresses": ${MY_POOLMEMBERS} }]
Try removing the square brackets and quotes around the ${MEMBERS} variable in the JSON. I spotted this example from one of Sebastian_Maniak 's guides:
in the module: MY_POOLMEMBERS = jsonencode(var.pool_members) in the json: "members": [{ "servicePort": 80, "shareNodes": true, "serverAddresses": ${MY_POOLMEMBERS} }]
thanks!!!!!!
It worked.
I don't know how I haven't tried this option before.
- Leslie_HubertusRet. Employee
JoshBecigneul FTW!
- Leslie_HubertusRet. Employee
Hi mihaic - Sebastian_Maniak may be able to help here. 🙂
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com