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

New Resouce azurerm_network_manager_deployment #20451

Merged
merged 17 commits into from
May 9, 2023

Conversation

teowa
Copy link
Contributor

@teowa teowa commented Feb 14, 2023

This is a special resouce with POST API to CRUD.
Reference:

  1. Configure Network Manager Deployment
  2. Swagger

Test:

make acctests SERVICE="network" TESTARGS="-parallel 20 -test.run=TestAccNetworkManager" TESTTIMEOUT='1440m' 
==> Checking that code complies with gofmt requirements...
==> Checking that Custom Timeouts are used...
==> Checking that acceptance test packages are used...
TF_ACC=1 go test -v ./internal/services/network -parallel 20 -test.run=TestAccNetworkManager -timeout 1440m -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccNetworkManager
=== RUN   TestAccNetworkManager/Commit
=== RUN   TestAccNetworkManager/Commit/keepOnDestroy
=== RUN   TestAccNetworkManager/Commit/purgeOnDestroy
=== RUN   TestAccNetworkManager/Commit/requiresImport
=== RUN   TestAccNetworkManager/Commit/basic
=== RUN   TestAccNetworkManager/Commit/basicAdmin
=== RUN   TestAccNetworkManager/Commit/complete
=== RUN   TestAccNetworkManager/Commit/update
--- PASS: TestAccNetworkManager (710.27s)
    --- PASS: TestAccNetworkManager/Commit (710.27s)
        --- PASS: TestAccNetworkManager/Commit/keepOnDestroy (123.07s)
        --- PASS: TestAccNetworkManager/Commit/purgeOnDestroy (130.61s)
        --- PASS: TestAccNetworkManager/Commit/requiresImport (86.63s)
        --- PASS: TestAccNetworkManager/Commit/basic (86.06s)
        --- PASS: TestAccNetworkManager/Commit/basicAdmin (84.48s)
        --- PASS: TestAccNetworkManager/Commit/complete (85.02s)
        --- PASS: TestAccNetworkManager/Commit/update (114.41s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/network       711.518s

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hey @teowa

Thanks for this PR.

Taking a look through here it appears this resource has a 1:1 relationship with Network Manager and as such should be embedded within that resource, rather than being a separate resource (potentially as two blocks/fields for connectivity and security_admin), which would also mean that we could remove the flag from the features block.

Would you be able to take a look into supporting this functionality within the azurerm_network_manager resource instead?

Thanks!

Comment on lines 44 to 67
"network_manager_id": {
Type: pluginsdk.TypeString,
Required: true,
ValidateFunc: validate.NetworkManagerID,
},

"location": commonschema.Location(),

"scope_access": {
Type: pluginsdk.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
string(network.ConfigurationTypeConnectivity),
string(network.ConfigurationTypeSecurityAdmin),
}, false),
},

"configuration_ids": {
Type: pluginsdk.TypeList,
Required: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
ValidateFunc: validation.StringIsNotEmpty,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

since this resource is 1:1 with the Network Manager, this should be embedded within the Network Manager resource as blocks rather than being a separate resource - presumably with one for connectivity and one for security_admin - which also removes the need for the flag within the features block, can we update this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A Network Manager can have more than one commit. Actually the commit is used to deploy specfic type of configuration to specific location follow a goal state model, so we design the ID format to be like /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Network/networkManagers/networkManager1/commit|eastus|Connectivity. From Portal:
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

wouldn't that just mean you allow multiple commit blocks in the network manager resource then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The dependency is that Commit depends on the Configurations, Configurations depends on Network Manager, and a Commit can contains more than one Configurations. An example is like:

resource "azurerm_network_manager" "test" {
  name                = "acctest-nm"
  resource_group_name = azurerm_resource_group.test.name
}

resource "azurerm_network_manager_connectivity_configuration" "test" {
  name                  = "acctest-nmcc"
  network_manager_id    = azurerm_network_manager.test.id
}

resource "azurerm_network_manager_commit" "test" {
  network_manager_id = azurerm_network_manager.test.id
  location           = "eastus"
  scope_access       = "Connectivity"
  configuration_ids  = [azurerm_network_manager_connectivity_configuration.test.id]
}

Allowing commits as blocks in the Network Manager will lead to cycle import.

Copy link
Contributor

Choose a reason for hiding this comment

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

@teowa per the link above, it appears that the Goal State Model is contrary to how Terraform Resources are expected to work - since at the end of the terraform apply the resource has to be in a fully provisioned/stable state - so the question becomes how does this resource make sense in Terraform?

Copy link
Contributor Author

@teowa teowa Apr 4, 2023

Choose a reason for hiding this comment

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

@katbyte , from the doc, Security admin rules are evaluated before network security rules. And I have also confirmed with service team that Network Manager will NOT touch NSGs. They are in different layers.

As for possible conflict with peering resource, can we addnotes in the provider docs, if users don't config Network Peering and Network Manger Commit together, (they can also do this if they know how the Network Manager scope works), conflict can be avoid in their config file. Per above, I think no computed or ignore_changes needs to be added. Is this OK?

Copy link
Collaborator

Choose a reason for hiding this comment

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

from the docs there, it seems like it starts an "eventually consistent" deployment. how do we, terraform, know when that is completed/done given there is nothign to poll on an ensure the create finished at the same time all these deployments finish?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can retrieve the deployment status from another API, a state.WaitForStateContext is added at https://github.com/hashicorp/terraform-provider-azurerm/pull/20451/files#diff-f7faa7358d61518bec904e6d50a8453bf5220356bdae2d40b01027c61babfabeR245, we will wait until the create /update and delete get fully finished.

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 thanks for the details

Copy link
Contributor Author

Choose a reason for hiding this comment

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

please continue to review this, thanks.

@teowa
Copy link
Contributor Author

teowa commented Mar 8, 2023

temp close this, please merge #20840 before this one.

@teowa teowa closed this Mar 8, 2023
@teowa teowa reopened this Mar 29, 2023
@teowa
Copy link
Contributor Author

teowa commented Apr 14, 2023

Hi, is there any update on this?

@teowa
Copy link
Contributor Author

teowa commented Apr 28, 2023

TF_ACC=1 go test -v ./internal/services/network -parallel 20 -test.run=TestAccNetworkManager -timeout 1440m -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccNetworkManager
=== RUN   TestAccNetworkManager/Deployment
=== RUN   TestAccNetworkManager/Deployment/requiresImport
=== RUN   TestAccNetworkManager/Deployment/basic
=== RUN   TestAccNetworkManager/Deployment/basicAdmin
=== RUN   TestAccNetworkManager/Deployment/complete
=== RUN   TestAccNetworkManager/Deployment/update
=== RUN   TestAccNetworkManager/Deployment/withTriggers
--- PASS: TestAccNetworkManager (900.32s)
    --- PASS: TestAccNetworkManager/Deployment (900.32s)
        --- PASS: TestAccNetworkManager/Deployment/requiresImport (137.46s)
        --- PASS: TestAccNetworkManager/Deployment/basic (125.70s)
        --- PASS: TestAccNetworkManager/Deployment/basicAdmin (129.49s)
        --- PASS: TestAccNetworkManager/Deployment/complete (126.64s)
        --- PASS: TestAccNetworkManager/Deployment/update (255.89s)
        --- PASS: TestAccNetworkManager/Deployment/withTriggers (125.15s)
PASS
ok  	github.com/hashicorp/terraform-provider-azurerm/internal/services/network	902.363s

@teowa
Copy link
Contributor Author

teowa commented Apr 28, 2023

Hi @manicminer, thanks for reviewing this. I have changed code per review comment, please kindly take another look.

@teowa teowa changed the title New Resouce azurerm_network_manager_commit New Resouce azurerm_network_manager_deployment Apr 28, 2023
@teowa
Copy link
Contributor Author

teowa commented May 9, 2023

image

Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

Many thanks for making the changes @teowa, this looks good to merge.

@manicminer manicminer merged commit cb1665a into hashicorp:main May 9, 2023
@github-actions github-actions bot added this to the v3.56.0 milestone May 9, 2023
manicminer added a commit that referenced this pull request May 9, 2023
@github-actions
Copy link

This functionality has been released in v3.56.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants