hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.29k stars 1.72k forks source link

Router interface API Documentation suggests that some attributes are required,But making API calls without these attributes also works #12485

Open AlfatahB opened 2 years ago

AlfatahB commented 2 years ago

Community Note

Terraform Version

Terraform v1.2.8

Affected Resource(s)

Steps to Reproduce

API Documentation suggests that:

Router interfaces. Each interface requires either one linked resource, (for example, linkedVpnTunnel), or IP address and IP address range (for example, ipRange), or both.

google_compute_router_interface in Terraform Provider is behaving correctly as per the above API docs. But, If I create Router and provide a Router interface without providing any of these attributes (i.e. either one linked resource, (for example, linkedVpnTunnel), or IP address and IP address range (for example, ipRange), or both), then it was being created. So, I raised a bug for the same.

References

edwardmedia commented 2 years ago

@AlfatahB can you share your debug log that can demo making API calls without these attributes also works?

AlfatahB commented 2 years ago

By making Create call (https://compute.googleapis.com/compute/v1/projects/project-name/regions/us-central1/routers) with the following request body, the router is being created along with interface without providing either linkedResources or ipRange Request Body for Post Call:

{
    "name": "test-router",
    "network": "https://www.googleapis.com/compute/v1/projects/project-name/global/networks/test-network",
    "interfaces": [
        {
            "name" : "test-router-interface"
           # Here, I am not providing the linkedResources or ipRange
        }
    ]
}

To confirm this, I have also made Read call (https://compute.googleapis.com/compute/v1/projects/project-name/regions/us-central1/routers) Response Body for Get call:

{
    "kind": "compute#routerList",
    "id": "projects/project-name/regions/us-central1/routers",
    "items": [
        {
            "kind": "compute#router",
            "id": "5155929330873040434",
            "creationTimestamp": "2022-09-08T03:15:57.123-07:00",
            "name": "test-router",
            "region": "https://www.googleapis.com/compute/v1/projects/project-name/regions/us-central1",
            "network": "https://www.googleapis.com/compute/v1/projects/project-name/global/networks/test-network",
            "interfaces": [
                {
                    "name": "test-router-interface"
                }
            ],
            "selfLink": "https://www.googleapis.com/compute/v1/projects/project-name/regions/us-central1/routers/test-router"
        }
    ],
    "selfLink": "https://www.googleapis.com/compute/v1/projects/project-name/regions/us-central1/routers"
}
edwardmedia commented 2 years ago

@shuyama1 shouldn't this be an API issue as well, related to b/241976681?

shuyama1 commented 1 year ago

This feature is implemented based on the API description. Filed a ticket b/248037977 against the upstream API to confirm if the requirements are still valid

AlfatahB commented 1 year ago

@shuyama1 Any updates regarding this?