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

Fixed the table azure_subnet to correctly populate the ip_configurations column value Closes #815 #822

Merged
merged 3 commits into from
Aug 20, 2024

Conversation

ParthaI
Copy link
Contributor

@ParthaI ParthaI commented Aug 20, 2024

Integration test logs

Logs
No env file present for the current environment:  staging 
 Falling back to .env config
No env file present for the current environment:  staging
customEnv TURBOT_TEST_EXPECTED_TIMEOUT undefined

SETUP: tests/azure_subnet []

PRETEST: tests/azure_subnet

TEST: tests/azure_subnet
Running terraform
data.azurerm_client_config.current: Reading...
data.azurerm_client_config.current: Read complete after 0s [id=Y2xpZW50Q29uZmlncy9jbGllbnRJZD0wNGIwNzc5NS04ZGRiLTQ2MWEtYmJlZS0wMmY5ZTFiZjdiNDY7b2JqZWN0SWQ9MDZmZDQ2YjAtYTg2Ny00OWExLWE0ZjEtZjc3Njg0NjVjYWJhO3N1YnNjcmlwdGlvbklkPWQ0NmQ3NDE2LWY5NWYtNDc3MS1iYmI1LTUyOWQ0Yzc2NjU5Yzt0ZW5hbnRJZD1jZGZmZDcwOC03ZGEwLTRjZWEtYWJlYi0wYTRjMzM0ZDdmNjQ=]
data.null_data_source.resource: Reading...
data.null_data_source.resource: Read complete after 0s [id=static]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # azurerm_resource_group.named_test_resource will be created
  + resource "azurerm_resource_group" "named_test_resource" {
      + id       = (known after apply)
      + location = "westus"
      + name     = "turbottest51213"
    }

  # azurerm_subnet.named_test_resource will be created
  + resource "azurerm_subnet" "named_test_resource" {
      + address_prefixes                               = [
          + "10.0.1.0/24",
        ]
      + default_outbound_access_enabled                = true
      + enforce_private_link_endpoint_network_policies = (known after apply)
      + enforce_private_link_service_network_policies  = (known after apply)
      + id                                             = (known after apply)
      + name                                           = "turbottest51213"
      + private_endpoint_network_policies              = (known after apply)
      + private_endpoint_network_policies_enabled      = (known after apply)
      + private_link_service_network_policies_enabled  = (known after apply)
      + resource_group_name                            = "turbottest51213"
      + virtual_network_name                           = "turbottest51213"

      + delegation {
          + name = "delegation"

          + service_delegation {
              + actions = [
                  + "Microsoft.Network/virtualNetworks/subnets/join/action",
                  + "Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action",
                ]
              + name    = "Microsoft.ContainerInstance/containerGroups"
            }
        }
    }

  # azurerm_virtual_network.named_test_resource will be created
  + resource "azurerm_virtual_network" "named_test_resource" {
      + address_space       = [
          + "10.0.0.0/16",
        ]
      + dns_servers         = (known after apply)
      + guid                = (known after apply)
      + id                  = (known after apply)
      + location            = "westus"
      + name                = "turbottest51213"
      + resource_group_name = "turbottest51213"
      + subnet              = (known after apply)
    }

Plan: 3 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + resource_aka       = (known after apply)
  + resource_aka_lower = (known after apply)
  + resource_id        = (known after apply)
  + resource_name      = "turbottest51213"
  + subscription_id    = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
azurerm_resource_group.named_test_resource: Creating...
azurerm_resource_group.named_test_resource: Still creating... [10s elapsed]
azurerm_resource_group.named_test_resource: Creation complete after 14s [id=/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/turbottest51213]
azurerm_virtual_network.named_test_resource: Creating...
azurerm_virtual_network.named_test_resource: Creation complete after 10s [id=/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/turbottest51213/providers/Microsoft.Network/virtualNetworks/turbottest51213]
azurerm_subnet.named_test_resource: Creating...
azurerm_subnet.named_test_resource: Creation complete after 8s [id=/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/turbottest51213/providers/Microsoft.Network/virtualNetworks/turbottest51213/subnets/turbottest51213]

Warning: Deprecated

  with data.null_data_source.resource,
  on variables.tf line 29, in data "null_data_source" "resource":
  29: data "null_data_source" "resource" {

The null_data_source was historically used to construct intermediate values
to re-use elsewhere in configuration, the same can now be achieved using
locals or the terraform_data resource type in Terraform 1.4 and later.

(and one more similar warning elsewhere)

Apply complete! Resources: 3 added, 0 changed, 0 destroyed.

Outputs:

resource_aka = "azure:///subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/turbottest51213/providers/Microsoft.Network/virtualNetworks/turbottest51213/subnets/turbottest51213"
resource_aka_lower = "azure:///subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/turbottest51213/providers/microsoft.network/virtualnetworks/turbottest51213/subnets/turbottest51213"
resource_id = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/turbottest51213/providers/Microsoft.Network/virtualNetworks/turbottest51213/subnets/turbottest51213"
resource_name = "turbottest51213"
subscription_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

Running SQL query: test-get-query.sql

Time: 1.8s. Rows returned: 1. Rows fetched: 1. Hydrate calls: 0.

Scans:
  1) azure_subnet.azure: Time: 1.5s. Fetched: 1. Hydrates: 0. Quals: name=turbottest51213, resource_group=turbottest51213, virtual_network_name=turbottest51213.

[
  {
    "address_prefix": "10.0.1.0/24",
    "delegations": [
      {
        "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/turbottest51213/providers/Microsoft.Network/virtualNetworks/turbottest51213/subnets/turbottest51213/delegations/delegation",
        "name": "delegation",
        "properties": {
          "serviceName": "Microsoft.ContainerInstance/containerGroups"
        },
        "type": "Microsoft.Network/virtualNetworks/subnets/delegations"
      }
    ],
    "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/turbottest51213/providers/Microsoft.Network/virtualNetworks/turbottest51213/subnets/turbottest51213",
    "name": "turbottest51213",
    "resource_group": "turbottest51213",
    "type": "Microsoft.Network/subnets",
    "virtual_network_name": "turbottest51213"
  }
]
✔ PASSED

Running SQL query: test-hydrate-query.sql

Time: 2.0s. Rows returned: 1. Rows fetched: 1. Hydrate calls: 0.

Scans:
  1) azure_subnet.azure: Time: 1.7s. Fetched: 1. Hydrates: 0. Quals: name=turbottest51213, resource_group=turbottest51213, virtual_network_name=turbottest51213.

[
  {
    "akas": [
      "azure:///subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/turbottest51213/providers/Microsoft.Network/virtualNetworks/turbottest51213/subnets/turbottest51213",
      "azure:///subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/turbottest51213/providers/microsoft.network/virtualnetworks/turbottest51213/subnets/turbottest51213"
    ],
    "name": "turbottest51213",
    "title": "turbottest51213"
  }
]
✔ PASSED

Running SQL query: test-list-query.sql

Time: 3.2s. Rows returned: 1. Rows fetched: 7. Hydrate calls: 0.

Scans:
  1) azure_subnet.azure: Time: 2.8s. Fetched: 7. Hydrates: 0. Quals: name=turbottest51213.

[
  {
    "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/turbottest51213/providers/Microsoft.Network/virtualNetworks/turbottest51213/subnets/turbottest51213",
    "name": "turbottest51213"
  }
]
✔ PASSED

Running SQL query: test-not-found-query.sql

Time: 2.2s. Rows returned: 0.
[]
✔ PASSED

Running SQL query: test-turbot-query.sql

Time: 2.7s. Rows returned: 1. Rows fetched: 1. Hydrate calls: 0.

Scans:
  1) azure_subnet.azure: Time: 2.0s. Fetched: 1. Hydrates: 0. Quals: name=turbottest51213, resource_group=turbottest51213, virtual_network_name=turbottest51213.

[
  {
    "akas": [
      "azure:///subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/turbottest51213/providers/Microsoft.Network/virtualNetworks/turbottest51213/subnets/turbottest51213",
      "azure:///subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/turbottest51213/providers/microsoft.network/virtualnetworks/turbottest51213/subnets/turbottest51213"
    ],
    "name": "turbottest51213",
    "title": "turbottest51213"
  }
]
✔ PASSED

TEARDOWN: tests/azure_subnet

SUMMARY:

1/1 passed.

Example query results

Results

I have the connected devices as follows:

Screenshot 2024-08-20 at 12 13 13 PM

Here is the result for the subnet.

> select name, jsonb_pretty(ip_configurations) from azure_subnet where name = 'turbottest38108'
+-----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| name            | jsonb_pretty                                                                                                                                                                                       |
+-----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| turbottest38108 | [                                                                                                                                                                                                  |
|                 |     {                                                                                                                                                                                              |
|                 |         "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/turbottest38108/providers/Microsoft.Network/loadBalancers/test53/frontendIPConfigurations/test53",               |
|                 |         "name": "test53",                                                                                                                                                                          |
|                 |         "type": "Microsoft.Network/loadBalancers/frontendIPConfigurations",                                                                                                                        |
|                 |         "properties": {                                                                                                                                                                            |
|                 |             "subnet": {                                                                                                                                                                            |
|                 |                 "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/turbottest38108/providers/Microsoft.Network/virtualNetworks/turbottest38108/subnets/turbottest38108"     |
|                 |             },                                                                                                                                                                                     |
|                 |             "privateIPAddress": "10.0.2.5",                                                                                                                                                        |
|                 |             "provisioningState": "Succeeded",                                                                                                                                                      |
|                 |             "privateIPAddressVersion": "IPv4",                                                                                                                                                     |
|                 |             "privateIPAllocationMethod": "Dynamic"                                                                                                                                                 |
|                 |         }                                                                                                                                                                                          |
|                 |     },                                                                                                                                                                                             |
|                 |     {                                                                                                                                                                                              |
|                 |         "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/turbottest38108/providers/Microsoft.Network/networkInterfaces/turbottest38108/ipConfigurations/turbottest38108", |
|                 |         "name": "turbottest38108",                                                                                                                                                                 |
|                 |         "type": "Microsoft.Network/networkInterfaces/ipConfigurations",                                                                                                                            |
|                 |         "properties": {                                                                                                                                                                            |
|                 |             "subnet": {                                                                                                                                                                            |
|                 |                 "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/turbottest38108/providers/Microsoft.Network/virtualNetworks/turbottest38108/subnets/turbottest38108"     |
|                 |             },                                                                                                                                                                                     |
|                 |             "primary": true,                                                                                                                                                                       |
|                 |             "privateIPAddress": "10.0.2.4",                                                                                                                                                        |
|                 |             "provisioningState": "Succeeded",                                                                                                                                                      |
|                 |             "privateIPAddressVersion": "IPv4",                                                                                                                                                     |
|                 |             "privateIPAllocationMethod": "Dynamic"                                                                                                                                                 |
|                 |         }                                                                                                                                                                                          |
|                 |     }                                                                                                                                                                                              |
|                 | ]                                                                                                                                                                                                  |
+-----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

@ParthaI ParthaI requested a review from misraved August 20, 2024 07:05
@ParthaI ParthaI self-assigned this Aug 20, 2024
@misraved misraved merged commit af6a80f into main Aug 20, 2024
1 check failed
@misraved misraved deleted the issue-815 branch August 20, 2024 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add connected_devices information in azure_virtual_network and azure_subnet tables
2 participants