Terraform v0.12.8
+ provider.google v2.14.0
+ provider.google-beta v2.14.0
+ provider.random v2.2.0
+ provider.template v2.1.2
{
"resource": {
"google_container_cluster": {
"sw01": {
"addons_config": {
"istio_config": {
"auth": "AUTH_MUTUAL_TLS",
"disabled": false
}
},
"depends_on": [
"google_project_service.enable_container_service"
],
"initial_node_count": 1,
"ip_allocation_policy": [
{
"use_ip_aliases": true,
"create_subnetwork": true
}]
,
"location": "europe-west1",
"master_auth": {
"client_certificate_config": {
"issue_client_certificate": false
},
"password": "",
"username": ""
},
"min_master_version": "1.13.7-gke.24",
"name": "sw01",
"network": "${google_compute_network.sw01.self_link}",
"provider": "google",
"remove_default_node_pool": true
}
},
}
}
Create cluster it alias_ip
Error: Incorrect attribute value type
on kubernetes.tf.json line 15, in resource.google_container_cluster.sw01:
15: "ip_allocation_policy": [
Inappropriate value for attribute "ip_allocation_policy": element 0:
attributes "cluster_ipv4_cidr_block", "cluster_secondary_range_name",
"node_ipv4_cidr_block", "services_ipv4_cidr_block",
"services_secondary_range_name", and "subnetwork_name" are required.
terraform applyI am using json instead of hcl
Please note I have tried with several different combinations of ip_allocation_policy, all leading to similar errors
Hi @ademariag! ip_allocation_policy is an unusual field in the provider, because it has a special property that we had to set to enable certain features to work with 0.12. This has the side effect that, when using JSON, you have to set all the fields for this block, even optional ones.
https://www.terraform.io/docs/configuration/attr-as-blocks.html has some more details, but the relevant quotes are:
The interpretation of these values in JSON syntax is, therefore, equivalent to that described under Arbitrary Expressions with Argument Syntax above, but expressed in JSON syntax instead.
and
Because of the rule that argument declarations like this fully override any default value, when creating a list-of-objects expression directly the usual handling of optional arguments does not apply, so all of the arguments must be assigned a value, even if it's an explicit null
tl;dr: I'd recommend modifying your config to look like this:
"ip_allocation_policy": [
{
"cluster_ipv4_cidr_block": null,
"cluster_secondary_range_name": null,
"node_ipv4_cidr_block": null,
"services_ipv4_cidr_block": null,
"services_secondary_range_name": null,
"subnetwork_name": null,
"use_ip_aliases": true,
"create_subnetwork": true
}]
,
I'm going to go ahead and close this issue out, but if it doesn't work or anything else comes up, we can reopen it.
FYI @danawillow that worked, thank you.
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!