Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inappropriate value for attribute "ip_allocation_policy" #4431

Closed
ademariag opened this issue Sep 9, 2019 · 4 comments
Closed

Inappropriate value for attribute "ip_allocation_policy" #4431

ademariag opened this issue Sep 9, 2019 · 4 comments
Assignees
Labels
bug forward/review In review; remove label to forward service/container

Comments

@ademariag
Copy link

ademariag commented Sep 9, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
  • If an issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to "hashibot", a community member has claimed the issue already.

Terraform Version

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

Affected Resource(s)

  • google_container_cluster

Terraform Configuration Files

{
  "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
      }   
    },
  }
} 

Debug Output

Panic Output

Expected Behavior

Create cluster it alias_ip

Actual Behavior

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.

Steps to Reproduce

  1. terraform apply

Important Factoids

I am using json instead of hcl

@ghost ghost added the bug label Sep 9, 2019
@ademariag
Copy link
Author

Please note I have tried with several different combinations of ip_allocation_policy, all leading to similar errors

@danawillow danawillow self-assigned this Sep 9, 2019
@danawillow
Copy link
Contributor

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.

@ademariag
Copy link
Author

FYI @danawillow that worked, thank you.

@ghost
Copy link

ghost commented Oct 10, 2019

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!

@ghost ghost locked and limited conversation to collaborators Oct 10, 2019
@github-actions github-actions bot added service/container forward/review In review; remove label to forward labels Jan 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug forward/review In review; remove label to forward service/container
Projects
None yet
Development

No branches or pull requests

2 participants