-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
[MS] provider/azurerm: New resource - Express Route Circuit #14265
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @whiskeyjay
Thanks for this PR - I've reviewed and left some comments in-line, but it generally looks good :)
Out of interest, is the list of Service Providers Name/Locations static, or can it change from time-to-time? (I'm wondering if it's worth some validation around this)
Thanks!
return err | ||
} | ||
|
||
if erc == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to place this inside the error statement above - and explicitly check for a 404 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That (check for 404) is done in the retrieveErcByResourceId function.
Required: true, | ||
}, | ||
|
||
"sku_tier": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seeing as we need multiple properties here, would it be worth making this it's own object to make it clearer? i.e.
sku {
family = "Metered"
tier = "Standard"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right!
"sku_tier": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Default: string(network.ExpressRouteCircuitSkuTierStandard), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we tend to make these explicit where possible, could we update this to remove the default and make this required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made "Required".
"sku_family": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Default: string(network.MeteredData), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(same here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made "Required".
"github.com/hashicorp/errwrap" | ||
) | ||
|
||
func extractResourceGroupAndErcName(resourceId string) (resourceGroup string, name string, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these methods going to be used outside of the Express Route resource? Otherwise would it make more sense for them to live in the resource until they're needed elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They will very likely be used by other types in the second part of Express Route work (peering). If not, I'll clean it up with peering support. Will that work? :)
The following attributes are exported: | ||
|
||
* `id` - The Resource ID of the ExpressRoute circuit. | ||
* `service_provider_provisioning_state` - The ServiceProviderProvisioningState state of the resource. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, I believe the only two states exposed for this field are going to be NotProvisioned
and Provisioned
- for when the resource doesn't exist, and does exist respectively. As such, is there much to be gained from exposing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my bad - I copied the description from the REST API doc - this is actually the circuit provisioning state from the service provider, not the state of the resource representing the circuit. Only when the service provider has done their work, this attribute's value will be Provisioned
and then further configuration of the ExpressRoute can be continued.
} | ||
|
||
func testAccAzureRMExpressRouteCircuit_basic(rInt int) string { | ||
return strings.Replace(` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to switch this out for a fmt.Sprintf
to match the other acceptance tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to avoid future errors like adding/removing one or more %d in the config string but forgot to match the number of parameters supplied in Sprintf. That said, I also understand it would be nice to have a uniform coding style. Please let me know if this is indeed a style issue, I will be happy to change it to match existing ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whiskeyjay so one option to avoid that issue when using a fmt.Sprintf
is to use the substitute value of %[1]d
to reference the first item rather than %d
for this purpose (as you've seen we've started wrapping the test strings in a method, rather than formatting the string inside of each test to avoid the argument mismatch issue).
But yes, it'd be nice to make this consistent with the other acceptance tests if possible :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tombuildsstuff got it.
return errwrap.Wrapf("Error Deleting ExpressRouteCircuit {{err}}", err) | ||
} | ||
|
||
d.SetId("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't needed in a Delete function - since the resource is removed from the state automatically :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
return errwrap.Wrapf("Error Parsing Azure Resource ID {{err}}", err) | ||
} | ||
|
||
_, err = ercClient.Delete(resGroup, name, make(chan struct{})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just return the result of this error, rather than checking the result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed a few comments and made changes accordingly. Still working on the rest.
"github.com/hashicorp/errwrap" | ||
) | ||
|
||
func extractResourceGroupAndErcName(resourceId string) (resourceGroup string, name string, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They will very likely be used by other types in the second part of Express Route work (peering). If not, I'll clean it up with peering support. Will that work? :)
Required: true, | ||
}, | ||
|
||
"sku_tier": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right!
"sku_tier": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Default: string(network.ExpressRouteCircuitSkuTierStandard), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made "Required".
"sku_family": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Default: string(network.MeteredData), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made "Required".
The following attributes are exported: | ||
|
||
* `id` - The Resource ID of the ExpressRoute circuit. | ||
* `service_provider_provisioning_state` - The ServiceProviderProvisioningState state of the resource. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my bad - I copied the description from the REST API doc - this is actually the circuit provisioning state from the service provider, not the state of the resource representing the circuit. Only when the service provider has done their work, this attribute's value will be Provisioned
and then further configuration of the ExpressRoute can be continued.
@tombuildsstuff I made a few changes based on review comments; have one question regarding style in acc test file. Looking forward to your reply. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @whiskeyjay
Thanks for the ongoing effort here, I've taken another look and left a couple of minor comments in-line, but this otherwise LGTM :)
Thanks!
} | ||
} | ||
|
||
func resourceArmExpressRouteCircuitCreate(d *schema.ResourceData, meta interface{}) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: since this is both Creating and Updating, could we rename it resourceArmExpressRouteCircuitCreateOrUpdate
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
serviceProviderName := d.Get("service_provider_name").(string) | ||
peeringLocation := d.Get("peering_location").(string) | ||
bandwidthInMbps := int32(d.Get("bandwidth_in_mbps").(int)) | ||
sku := expandExpressRouteCircuitSku(d.Get("sku").(*schema.Set)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we pass in d
here and have the method take care of the casting, to be consistent with the other resources?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made changes in test (Replace -> Sprintf), and changed Create to CreateOrUpdate.
} | ||
} | ||
|
||
func resourceArmExpressRouteCircuitCreate(d *schema.ResourceData, meta interface{}) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
serviceProviderName := d.Get("service_provider_name").(string) | ||
peeringLocation := d.Get("peering_location").(string) | ||
bandwidthInMbps := int32(d.Get("bandwidth_in_mbps").(int)) | ||
sku := expandExpressRouteCircuitSku(d.Get("sku").(*schema.Set)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} | ||
|
||
func testAccAzureRMExpressRouteCircuit_basic(rInt int) string { | ||
return strings.Replace(` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tombuildsstuff got it.
Hi @whiskeyjay Thanks for pushing the latest changes to this PR. I've taken another look, pushed a minor tweak for consistency and run the tests and this LGTM :)
Thanks! |
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
#14122 Adding basic support for Express Route Circuit.
Setting up an Express Route Circuit involves two major steps:
This change enables the first step, once the resource is created, the service key is returned as an attribute (see documentation).
Peering setup support is still underway, will be in another PR.
Tests: