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

AV-78889 - VNET peering azure #216

Merged
merged 26 commits into from
Sep 25, 2024
Merged

AV-78889 - VNET peering azure #216

merged 26 commits into from
Sep 25, 2024

Conversation

PaulomeeCb
Copy link
Contributor

@PaulomeeCb PaulomeeCb commented Aug 20, 2024

Jira

Description

Please include a summary of the fix/feature/change, including any relevant motivation and context.

Type of Change

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR.
  • This change requires a documentation update
  • Documentation fix/enhancement

Manual Testing Approach

How was this change tested and do you have evidence? (REQUIRED: Select at least 1)

  • Manually tested
  • Unit tested
  • Acceptance tested
  • Unable to test / will not test (Please provide comments in section below)

Testing

Get Azure VNET Peering CLI Command API-

  1. Error received when trying to access the command without admin consent granted-
Planning failed. Terraform encountered an error while generating this plan.
╷
│ Error: Error Reading Azure network peer command
│ 
│   with data.couchbase-capella_azure_network_peer_command.azure_network_peer_command,
│   on get_network_peer_command.tf line 5, in data "couchbase-capella_azure_network_peer_command" "azure_network_peer_command":
│    5: data "couchbase-capella_azure_network_peer_command" "azure_network_peer_command" {
│ 
│ Could not read Azure network peer command: unexpected code: 422, expected: 200, body: {"code":4061,"hint":"Returned when trying to retrieve command when the admin consent has not been granted by the customer or the consent
│ granted by the customer has not been successfully verified.","httpStatusCode":422,"message":"Unable to retrieve role assignment command. Admin consent not granted or failed to verify admin consent granted to the AD app for vnet
│ peering.  Please try granting the admin consent and retry retrieving command again."}null
╵
Screen Shot 2024-08-21 at 12 10 52 PM

Terraform apply-

 terraform apply
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - couchbasecloud/couchbase-capella in /Users/paulomee.de/go/bin
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases.
╵
data.couchbase-capella_azure_network_peer_command.azure_network_peer_command: Reading...
data.couchbase-capella_azure_network_peer_command.azure_network_peer_command: Read complete after 0s

Changes to Outputs:
  + azure_network_peer_command = {
      + cluster_id                     = "ffffffff-aaaa-1414-eeee-000000000000"
      + command                        = "az role assignment create --assignee-object-id ffffffff-aaaa-1414-eeee-000000000000 --role \"Network Contributor\" --scope /subscriptions/ffffffff-aaaa-1414-eeee-000000000000/resourceGroups/peerer_test/providers/Microsoft.Network/VirtualNetworks/vnet-test --assignee-principal-type ServicePrincipal"
      + organization_id                = "ffffffff-aaaa-1414-eeee-000000000000"
      + project_id                     = "ffffffff-aaaa-1414-eeee-000000000000"
      + resource_group                 = "peerer_test"
      + subscription_id                = "ffffffff-aaaa-1414-eeee-000000000000"
      + tenant_id                      = "ffffffff-aaaa-1414-eeee-000000000000"
      + vnet_id                        = "vnet-test"
      + vnet_peering_service_principal = "ffffffff-aaaa-1414-eeee-000000000000"
    }

You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes


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

Outputs:

azure_network_peer_command = {
  "cluster_id" = "ffffffff-aaaa-1414-eeee-000000000000"
  "command" = "az role assignment create --assignee-object-id ffffffff-aaaa-1414-eeee-000000000000 --role \"Network Contributor\" --scope /subscriptions/ffffffff-aaaa-1414-eeee-000000000000/resourceGroups/peerer_test/providers/Microsoft.Network/VirtualNetworks/vnet-test --assignee-principal-type ServicePrincipal"
  "organization_id" = "ffffffff-aaaa-1414-eeee-000000000000"
  "project_id" = "ffffffff-aaaa-1414-eeee-000000000000"
  "resource_group" = "peerer_test"
  "subscription_id" = "ffffffff-aaaa-1414-eeee-000000000000"
  "tenant_id" = "ffffffff-aaaa-1414-eeee-000000000000"
  "vnet_id" = "vnet-test"
  "vnet_peering_service_principal" = "ffffffff-aaaa-1414-eeee-000000000000"
}
Screen Shot 2024-08-22 at 5 01 28 PM Screen Shot 2024-08-22 at 5 01 14 PM

Create Network Peering API-

terraform plan

terraform plan
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - couchbasecloud/couchbase-capella in /Users/paulomee.de/go/bin
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases.
╵
data.couchbase-capella_network_peers.existing_network_peers: Reading...
data.couchbase-capella_network_peers.existing_network_peers: Read complete after 0s

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:

  # couchbase-capella_network_peer.new_network_peer will be created
  + resource "couchbase-capella_network_peer" "new_network_peer" {
      + audit           = (known after apply)
      + cluster_id      = "ffffffff-aaaa-1414-eeee-00000000000"
      + commands        = (known after apply)
      + id              = (known after apply)
      + name            = "VNETPeerTFTestAZURE"
      + organization_id = "ffffffff-aaaa-1414-eeee-00000000000"
      + project_id      = "ffffffff-aaaa-1414-eeee-00000000000"
      + provider_config = {
          + azure_config = {
              + cidr            = "10.6.0.0/16"
              + provider_id     = (known after apply)
              + resource_group  = "test-rg"
              + subscription_id = "ffffffff-aaaa-1414-eeee-00000000000"
              + tenant_id       = "ffffffff-aaaa-1414-eeee-00000000000"
              + vnet_id         = "test-vnet"
            }
        }
      + provider_type   = "azure"
      + status          = (known after apply)
    }

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

Changes to Outputs:
  + network_peers_list = {
      + cluster_id      = "ffffffff-aaaa-1414-eeee-00000000000"
      + data            = [
          + {
              + audit           = {
                  + created_at  = "2024-08-23 23:30:39.790107885 +0000 UTC"
                  + created_by  = "s10qrydhDaic9GsWZ6BYpJfSK7wARDCv"
                  + modified_at = "2024-08-23 23:35:39.359925093 +0000 UTC"
                  + modified_by = "ffffffff-aaaa-1414-eeee-00000000000"
                  + version     = 6
                }
              + id              = "ffffffff-aaaa-1414-eeee-00000000000"
              + name            = "VNETPeerTFTestAZURE"
              + provider_config = {
                  + aws_config   = null
                  + azure_config = {
                      + cidr            = "10.6.0.0/16"
                      + provider_id     = ""
                      + resource_group  = "\"test-rg\""
                      + subscription_id = "\"ffffffff-aaaa-1414-eeee-00000000000\""
                      + tenant_id       = "\"ffffffff-aaaa-1414-eeee-00000000000\""
                      + vnet_id         = "\"test-vnet\""
                    }
                  + gcp_config   = null
                }
              + status          = {
                  + reasoning = ""
                  + state     = "failed"
                }
            },
        ]
      + organization_id = "ffffffff-aaaa-1414-eeee-00000000000"
      + project_id      = "ffffffff-aaaa-1414-eeee-00000000000"
    }
  + new_network_peer   = {
      + audit           = (known after apply)
      + cluster_id      = "ffffffff-aaaa-1414-eeee-00000000000"
      + commands        = (known after apply)
      + id              = (known after apply)
      + name            = "VNETPeerTFTestAZURE"
      + organization_id = "ffffffff-aaaa-1414-eeee-00000000000"
      + project_id      = "ffffffff-aaaa-1414-eeee-00000000000"
      + provider_config = {
          + aws_config   = null
          + azure_config = {
              + cidr            = "10.6.0.0/16"
              + provider_id     = (known after apply)
              + resource_group  = "test-rg"
              + subscription_id = "ffffffff-aaaa-1414-eeee-00000000000"
              + tenant_id       = "ffffffff-aaaa-1414-eeee-00000000000"
              + vnet_id         = "test-vnet"
            }
          + gcp_config   = null
        }
      + provider_type   = "azure"
      + status          = (known after apply)
    }
  + peer_id            = (known after apply)

terraform apply

terraform apply
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - couchbasecloud/couchbase-capella in /Users/paulomee.de/go/bin
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases.
╵
data.couchbase-capella_network_peers.existing_network_peers: Reading...
data.couchbase-capella_network_peers.existing_network_peers: Read complete after 0s

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:

  # couchbase-capella_network_peer.new_network_peer will be created
  + resource "couchbase-capella_network_peer" "new_network_peer" {
      + audit           = (known after apply)
      + cluster_id      = "ffffffff-aaaa-1414-eeee-00000000000"
      + commands        = (known after apply)
      + id              = (known after apply)
      + name            = "VNETPeerTFTestAZURE"
      + organization_id = "ffffffff-aaaa-1414-eeee-00000000000"
      + project_id      = "ffffffff-aaaa-1414-eeee-00000000000"
      + provider_config = {
          + azure_config = {
              + cidr            = "10.6.0.0/16"
              + provider_id     = (known after apply)
              + resource_group  = "test-rg"
              + subscription_id = "ffffffff-aaaa-1414-eeee-00000000000"
              + tenant_id       = "ffffffff-aaaa-1414-eeee-00000000000"
              + vnet_id         = "test-vnet"
            }
        }
      + provider_type   = "azure"
      + status          = (known after apply)
    }

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

Changes to Outputs:
  + network_peers_list = {
      + cluster_id      = "ffffffff-aaaa-1414-eeee-00000000000"
      + data            = [
          + {
              + audit           = {
                  + created_at  = "2024-08-23 23:30:39.790107885 +0000 UTC"
                  + created_by  = "s10qrydhDaic9GsWZ6BYpJfSK7wARDCv"
                  + modified_at = "2024-08-23 23:35:39.359925093 +0000 UTC"
                  + modified_by = "ffffffff-aaaa-1414-eeee-00000000000"
                  + version     = 6
                }
              + id              = "ffffffff-aaaa-1414-eeee-00000000000"
              + name            = "VNETPeerTFTestAZURE"
              + provider_config = {
                  + aws_config   = null
                  + azure_config = {
                      + cidr            = "10.6.0.0/16"
                      + provider_id     = ""
                      + resource_group  = "\"test-rg\""
                      + subscription_id = "\"ffffffff-aaaa-1414-eeee-00000000000\""
                      + tenant_id       = "\"ffffffff-aaaa-1414-eeee-00000000000\""
                      + vnet_id         = "\"test-vnet\""
                    }
                  + gcp_config   = null
                }
              + status          = {
                  + reasoning = ""
                  + state     = "failed"
                }
            },
        ]
      + organization_id = "ffffffff-aaaa-1414-eeee-00000000000"
      + project_id      = "ffffffff-aaaa-1414-eeee-00000000000"
    }
  + new_network_peer   = {
      + audit           = (known after apply)
      + cluster_id      = "ffffffff-aaaa-1414-eeee-00000000000"
      + commands        = (known after apply)
      + id              = (known after apply)
      + name            = "VNETPeerTFTestAZURE"
      + organization_id = "ffffffff-aaaa-1414-eeee-00000000000"
      + project_id      = "ffffffff-aaaa-1414-eeee-00000000000"
      + provider_config = {
          + aws_config   = null
          + azure_config = {
              + cidr            = "10.6.0.0/16"
              + provider_id     = (known after apply)
              + resource_group  = "test-rg"
              + subscription_id = "ffffffff-aaaa-1414-eeee-00000000000"
              + tenant_id       = "ffffffff-aaaa-1414-eeee-00000000000"
              + vnet_id         = "test-vnet"
            }
          + gcp_config   = null
        }
      + provider_type   = "azure"
      + status          = (known after apply)
    }
  + peer_id            = (known after apply)

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

couchbase-capella_network_peer.new_network_peer: Creating...
couchbase-capella_network_peer.new_network_peer: Still creating... [10s elapsed]
couchbase-capella_network_peer.new_network_peer: Still creating... [20s elapsed]
couchbase-capella_network_peer.new_network_peer: Still creating... [30s elapsed]
couchbase-capella_network_peer.new_network_peer: Still creating... [40s elapsed]
couchbase-capella_network_peer.new_network_peer: Creation complete after 43s [id=ffffffff-aaaa-1414-eeee-00000000000]

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

Outputs:

network_peers_list = {
  "cluster_id" = "ffffffff-aaaa-1414-eeee-00000000000"
  "data" = tolist([
    {
      "audit" = {
        "created_at" = "2024-08-23 23:30:39.790107885 +0000 UTC"
        "created_by" = "s10qrydhDaic9GsWZ6BYpJfSK7wARDCv"
        "modified_at" = "2024-08-23 23:35:39.359925093 +0000 UTC"
        "modified_by" = "ffffffff-aaaa-1414-eeee-00000000000"
        "version" = 6
      }
      "id" = "ffffffff-aaaa-1414-eeee-00000000000"
      "name" = "VNETPeerTFTestAZURE"
      "provider_config" = {
        "aws_config" = null /* object */
        "azure_config" = {
          "cidr" = "10.6.0.0/16"
          "provider_id" = ""
          "resource_group" = "\"test-rg\""
          "subscription_id" = "\"ffffffff-aaaa-1414-eeee-00000000000\""
          "tenant_id" = "\"ffffffff-aaaa-1414-eeee-00000000000\""
          "vnet_id" = "\"test-vnet\""
        }
        "gcp_config" = null /* object */
      }
      "status" = {
        "reasoning" = ""
        "state" = "failed"
      }
    },
  ])
  "organization_id" = "ffffffff-aaaa-1414-eeee-00000000000"
  "project_id" = "ffffffff-aaaa-1414-eeee-00000000000"
}
new_network_peer = {
  "audit" = {
    "created_at" = "2024-08-24 00:01:23.524305127 +0000 UTC"
    "created_by" = "s10qrydhDaic9GsWZ6BYpJfSK7wARDCv"
    "modified_at" = "2024-08-24 00:02:05.606678591 +0000 UTC"
    "modified_by" = "s10qrydhDaic9GsWZ6BYpJfSK7wARDCv"
    "version" = 2
  }
  "cluster_id" = "ffffffff-aaaa-1414-eeee-00000000000"
  "commands" = toset([])
  "id" = "ffffffff-aaaa-1414-eeee-00000000000"
  "name" = "VNETPeerTFTestAZURE"
  "organization_id" = "ffffffff-aaaa-1414-eeee-00000000000"
  "project_id" = "ffffffff-aaaa-1414-eeee-00000000000"
  "provider_config" = {
    "aws_config" = null /* object */
    "azure_config" = {
      "cidr" = "10.6.0.0/16"
      "provider_id" = "/subscriptions/ffffffff-aaaa-1414-eeee-00000000000/resourceGroups/rg-ffffffff-aaaa-1414-eeee-00000000000/providers/Microsoft.Network/virtualNetworks/cc-ffffffff-aaaa-1414-eeee-00000000000/virtualNetworkPeerings/cc-ffffffff-aaaa-1414-eeee-00000000000-test-vnet"
      "resource_group" = "test-rg"
      "subscription_id" = "ffffffff-aaaa-1414-eeee-00000000000"
      "tenant_id" = "ffffffff-aaaa-1414-eeee-00000000000"
      "vnet_id" = "test-vnet"
    }
    "gcp_config" = null /* object */
  }
  "provider_type" = "azure"
  "status" = {
    "reasoning" = ""
    "state" = "complete"
  }
}
peer_id = "ffffffff-aaaa-1414-eeee-00000000000"


Network peering record -
Screen Shot 2024-08-23 at 4 47 15 PM

Remaining all operations are in the README files.

NOTE: Getting_started folder already has an example for VPC Peering hence not updating that again.

Testing

Required Checklist:

  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if required)
  • I have run make fmt and formatted my code
  • I have made sure that no schema field is marked with both requiresReplace and computed

Further comments

@PaulomeeCb PaulomeeCb requested review from a team as code owners August 20, 2024 00:22
@PaulomeeCb PaulomeeCb marked this pull request as draft August 20, 2024 00:22
@PaulomeeCb PaulomeeCb marked this pull request as ready for review August 24, 2024 00:32
@PaulomeeCb PaulomeeCb self-assigned this Aug 24, 2024
@PaulomeeCb PaulomeeCb requested a review from a-atri August 26, 2024 16:36
SaicharanCB
SaicharanCB previously approved these changes Sep 12, 2024
Copy link
Contributor

@SaicharanCB SaicharanCB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Co-authored-by: aniket-Kumar-c <115682403+aniket-Kumar-c@users.noreply.github.com>
Copy link
Collaborator

@aniket-Kumar-c aniket-Kumar-c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@PaulomeeCb PaulomeeCb merged commit 0f5fcfe into main Sep 25, 2024
4 checks passed
Lagher0 added a commit that referenced this pull request Oct 6, 2024
…cket

* origin/main:
  AV-78889 - VNET peering azure (#216)
  Av 87139 fix gorunner version (#232)
  Av 87139 fix gorunner version (#231)
  Av 87139 fix gorunner version (#230)
  AV-87139 fix gorunner version (#229)
  Updating the version for gorunner (#228)
  AV-87077 | handle computed values in acc test (#227)
  [AV-86105] initialized autoexpansion field with null value (#226)
  [AV-86503] Updated the changelog (#221)
  [AV-86224] Generated docs for Terraform V1.3.0 (#220)
  [AV-86845] Deprecate the `configurationType` attribute in the cluster resource (#222)
  Bump github.com/hashicorp/terraform-plugin-go from 0.22.1 to 0.23.0 (#193)
  Bump github.com/hashicorp/terraform-plugin-framework from 1.6.1 to 1.9.0 (#201)
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.

4 participants