-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add support for Azure LB Standard and Public IP Standard #665
Add support for Azure LB Standard and Public IP Standard #665
Conversation
@tombuildsstuff would you mind taking a peep at 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.
hey @justaugustus
Thanks for this PR - I've taken a look through and left some comments in-line but this is off to a good start. From what I can see there's three things missing to be able to merge this:
- We need to set the field
sku
in the Read function like here https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/azurerm/resource_arm_loadbalancer.go#L181 - we can handle existing LB's without a SKU set via:
if sku := loadBalancer.Sku; sku != nil {
d.Set("sku", string(sku.Name))
}
-
We need to add an acceptance test for a
Standard
SKU Load Balancer - here's how we test the Basic SKU - we should only need to setsku = "standard"
since the other scenarios / combinations are tested via the Basic SKU (which is fine for now) -
Document the new
sku
field to mention there's two possible values; we'd tend to make this something similar to:
* `sku` - (Optional) The Name of the SKU to use for this Load Balancer. Accepted values are `Basic` and `Standard`. Defaults to `Basic`
That said - this is off to a good start and I've left some other comments in-line as appropriate :)
Thanks!
azurerm/resource_arm_loadbalancer.go
Outdated
@@ -114,6 +119,7 @@ func resourceArmLoadBalancerCreate(d *schema.ResourceData, meta interface{}) err | |||
name := d.Get("name").(string) | |||
location := d.Get("location").(string) | |||
resGroup := d.Get("resource_group_name").(string) | |||
sku := convertSkuStringToLoadBalancerSku(d.Get("sku").(string)) |
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.
rather than parsing this out I think we can make this network.LoadBalancerSkuName(d.Get("sku").(string))
?
azurerm/resource_arm_loadbalancer.go
Outdated
@@ -100,6 +100,11 @@ func resourceArmLoadBalancer() *schema.Resource { | |||
}, | |||
}, | |||
|
|||
"sku": { | |||
Type: schema.TypeString, | |||
Required: true, |
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.
from what I can tell existing Load Balancers are of the Basic SKU; so we can instead default this to Basic
and make this Optional; like so:
Default: string(network.LoadBalancerSkuNameBasic),
Optional: true,
^ this will mean that existing users don't need to specify the SKU (or update the configuration) for any existing Load Balancers. We can also extend this to add Validation and allow mixed-case strings (e.g. Basic
and basic
) via:
ValidateFunc: validation.StringInSlice([]string{
string(network.LoadBalancerSkuNameBasic),
string(network.LoadBalancerSkuNameStandard),
}, true),
DiffSupressFunc: ignoreCaseDiffSuppressFunc,
@tombuildsstuff Thanks so much for the quick CR! I've addressed your notes and have a few follow-up questions...
|
Each of the acceptance tests suffixes the resource names (in this case the LB Name) with a random integer/string to make the name unique across tests - so there shouldn't be any issues here.
Ideally it should be split out into another PR (which we can merge before this one) - but given they're interdependent I don't see any harm combining them into one if that's easier :) Thanks! |
I'll send another PR for the Public IP Standard SKU stuff. |
@justaugustus , thanks for your contribution. Thanks. |
93ee2fb
to
209b76f
Compare
Hey @tombuildsstuff! I added acceptance tests, but I was thinking through a few additional cases and a little unsure about how to approach them: LBTest SKU:
Test frontend IP config:
PIPTest SKU:
Could you take another sweep through this? |
@tombuildsstuff did you have a chance to take another look at 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.
@justaugustus I found a couple cleanup things if you don't mind addressing those and then @tombuildsstuff can take another pass at this.
resource "azurerm_lb" "test" { | ||
name = "arm-test-loadbalancer-%d" | ||
location = "${azurerm_resource_group.test.location}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" |
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.
got some mixed tabs and spaces 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.
@paultyng I'm noticing this across multiple files in the provider... are tabs or spaces preferred?
azurerm/resource_arm_public_ip.go
Outdated
Optional: true, | ||
Default: string(network.PublicIPAddressSkuNameBasic), | ||
ForceNew: true, | ||
ValidateFunc: validatePublicIpSku, |
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 could just be StringInSlice
couldn't it?
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.
@paultyng I was mimicking the other validation functions in that file and figured it could be reused in the acceptance tests, similar to:
- https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/azurerm/resource_arm_public_ip_test.go#L41
- https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/azurerm/resource_arm_public_ip_test.go#L73
Is there a preferred approach?
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.
It depends what's being tested - but in general we're using the Constants/Enums in the SDK via the StringInSlice
(at least for Strings) for newer resources; given these constants exist - could we switch this for a StringInSlice
?
name = "acctestpublicip-%d" | ||
location = "${azurerm_resource_group.test.location}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
public_ip_address_allocation = "static" |
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.
mixed tabs and spaces
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.
@paultyng I'm noticing this across multiple files in the provider... are tabs or spaces preferred?
* `public_ip_address_allocation` - (Required) Defines whether the IP address is stable or dynamic. Options are Static or Dynamic. | ||
* `sku` - (Optional) The SKU of the Public IP. Accepted values are `Basic` and `Standard`. Defaults to `Basic`. | ||
|
||
~> **Note** Public IP Standard SKUs require `public_ip_address_allocation` to be set to `static`. |
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.
Should this be in a validation?
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.
@paultyng Agreed that that should be in a validation as well!
I dropped a note (#665 (comment)) hoping for a nudge in the right direction re: the structuring the tests correctly and figured adding something in the docs was a good start while waiting for a response.
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.
@justaugustus apologies for the delayed response here.
At the current time it's only possible to access the value of that specific field in the validation method on the Schema - as such I believe we'd need to do this in the resourceArmPublicIpCreate
method?
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've added a commit to explain that this feature is still in Preview and needs to be opted-in
* Set as optional parameter * Set default `sku` value * Set `ForceNew: true` (SKUs are immutable) * Add validation for accepted SKU values ("Basic", "Standard") * Remove SKU conversion func
8f3236c
to
69581d8
Compare
@tombuildsstuff / @paultyng -- |
@justaugustus hey - just to let you know that now the SDK upgrade work is completed that I'm hoping to take a look into this later today (apologies for the delay here - we've been trying to minimise merge conflicts during the SDK migration) :) |
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.
hey @justaugustus
Thanks for pushing those updates - apologies for the delayed re-review here.
I've taken a look through and have left a comment in-line which I'll push a commit to resolve - but this otherwise LGTM. I'll kick off the test suite now
Thanks!
azurerm/resource_arm_public_ip.go
Outdated
} | ||
|
||
if resp.PublicIPAddressPropertiesFormat.DNSSettings != nil && resp.PublicIPAddressPropertiesFormat.DNSSettings.Fqdn != nil && *resp.PublicIPAddressPropertiesFormat.DNSSettings.Fqdn != "" { | ||
d.Set("fqdn", resp.PublicIPAddressPropertiesFormat.DNSSettings.Fqdn) |
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 can remove this line, since it's set below: https://github.com/terraform-providers/terraform-provider-azurerm/pull/665/files#diff-ed59d26a8bebf9bf3b188b200b02dd27L193
changes have been pushed since
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.
Given this functionality is in Preview - I've added a couple of comments about documenting this (I'll push a commit to fix this shortly).
* `public_ip_address_allocation` - (Required) Defines whether the IP address is stable or dynamic. Options are Static or Dynamic. | ||
* `sku` - (Optional) The SKU of the Public IP. Accepted values are `Basic` and `Standard`. Defaults to `Basic`. | ||
|
||
~> **Note** Public IP Standard SKUs require `public_ip_address_allocation` to be set to `static`. |
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've added a commit to explain that this feature is still in Preview and needs to be opted-in
@@ -45,6 +45,7 @@ The following arguments are supported: | |||
* `resource_group_name` - (Required) The name of the resource group in which to create the LoadBalancer. | |||
* `location` - (Required) Specifies the supported Azure location where the resource exists. | |||
* `frontend_ip_configuration` - (Optional) A frontend ip configuration block as documented below. | |||
* `sku` - (Optional) The SKU of the Azure Load Balancer. Accepted values are `Basic` and `Standard`. Defaults to `Basic`. |
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've added a commit to explain that this feature is still in Preview and needs to be opted-in
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.
LGTM 👍
🎉 |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
Ref: #579