-
Notifications
You must be signed in to change notification settings - Fork 5k
azurerm_nat_gateway/azurerm_public_ip/azurerm_public_ip_prefix - support for new SKU StandardV2
#31197
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
azurerm_nat_gateway/azurerm_public_ip/azurerm_public_ip_prefix - support for new SKU StandardV2
#31197
Changes from 14 commits
5e0cac4
8669186
1ca4e10
c1dcf3c
e882770
9cd164f
f5906bd
66824ac
69e74c7
e3c8b25
d8efc68
574846b
d626e58
348e749
2de750c
79d6261
d53603e
1c0a85c
aa8b5d5
a1c8270
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,15 +74,27 @@ func resourceNatGatewaySchema() map[string]*pluginsdk.Schema { | |
| }, | ||
|
|
||
| "sku_name": { | ||
| Type: pluginsdk.TypeString, | ||
| Optional: true, | ||
| Default: string(natgateways.NatGatewaySkuNameStandard), | ||
| ValidateFunc: validation.StringInSlice([]string{ | ||
| string(natgateways.NatGatewaySkuNameStandard), | ||
| }, false), | ||
| Type: pluginsdk.TypeString, | ||
| Optional: true, | ||
| Default: string(natgateways.NatGatewaySkuNameStandard), | ||
| ValidateFunc: validation.StringInSlice(natgateways.PossibleValuesForNatGatewaySkuName(), false), | ||
| }, | ||
|
|
||
| "zones": commonschema.ZonesMultipleOptionalForceNew(), | ||
| "zones": { | ||
| Type: schema.TypeSet, | ||
| Optional: true, | ||
| // NOTE: O+C Azure may return availability zones from the API when not specified by the user | ||
| Computed: true, | ||
| ForceNew: true, | ||
| Elem: &schema.Schema{ | ||
| Type: schema.TypeString, | ||
| ValidateFunc: validation.StringInSlice([]string{ | ||
| "1", | ||
| "2", | ||
| "3", | ||
| }, false), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should start limiting input to
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated; now we just check that it isn't an empty string. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from PG here - new creates of Basic SKU public IP resources as of March 2025 deprecation date is not supported. We are working on blocking in NRP, just hasn't rolled out yet. |
||
| }, | ||
| }, | ||
|
|
||
| "resource_guid": { | ||
| Type: pluginsdk.TypeString, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ package network | |||||
|
|
||||||
| import ( | ||||||
| "context" | ||||||
| "errors" | ||||||
| "fmt" | ||||||
| "log" | ||||||
| "strings" | ||||||
|
|
@@ -109,10 +110,7 @@ func resourcePublicIp() *pluginsdk.Resource { | |||||
| ForceNew: true, | ||||||
| Default: string(publicipaddresses.PublicIPAddressSkuNameStandard), | ||||||
| // https://azure.microsoft.com/en-us/updates/upgrade-to-standard-sku-public-ip-addresses-in-azure-by-30-september-2025-basic-sku-will-be-retired/ | ||||||
|
sreallymatt marked this conversation as resolved.
|
||||||
| ValidateFunc: validation.StringInSlice([]string{ | ||||||
| string(publicipaddresses.PublicIPAddressSkuNameBasic), | ||||||
| string(publicipaddresses.PublicIPAddressSkuNameStandard), | ||||||
| }, false), | ||||||
| ValidateFunc: validation.StringInSlice(publicipaddresses.PossibleValuesForPublicIPAddressSkuName(), false), | ||||||
|
sreallymatt marked this conversation as resolved.
|
||||||
| }, | ||||||
|
|
||||||
| "sku_tier": { | ||||||
|
|
@@ -182,13 +180,38 @@ func resourcePublicIp() *pluginsdk.Resource { | |||||
| }, | ||||||
|
|
||||||
| CustomizeDiff: pluginsdk.CustomDiffWithAll( | ||||||
| pluginsdk.CustomizeDiffShim(func(_ context.Context, d *pluginsdk.ResourceDiff, _ interface{}) error { | ||||||
| if !isPublicIPBasicSkuDeprecatedForCreation() { | ||||||
| return nil | ||||||
| } | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little confused as to why this function is here,
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated, this is removed. |
||||||
|
|
||||||
| sku := d.Get("sku").(string) | ||||||
| if strings.EqualFold(sku, string(publicipaddresses.PublicIPAddressSkuNameBasic)) && d.HasChanges("name", "resource_group_name", "location", "allocation_method", "edge_zone", "ip_version", "sku", "sku_tier", "public_ip_prefix_id", "ip_tags", "zones") { | ||||||
| return errors.New(publicIPBasicSkuCreateDeprecationMessage) | ||||||
| } | ||||||
|
|
||||||
| return nil | ||||||
| }), | ||||||
| pluginsdk.ForceNewIfChange("domain_name_label_scope", func(ctx context.Context, old, new, meta interface{}) bool { | ||||||
| return old.(string) != "" || new.(string) == "" | ||||||
| }), | ||||||
| ), | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| const publicIPBasicSkuCreateDeprecationMessage = "creation of new `Basic` SKU public IP addresses is no longer permitted following its deprecation on March 31, 2025. This also affects `allocation_method` set to `Dynamic`, as it is only available with the `Basic` SKU. Existing `Basic` SKU public IP addresses can continue to be used until September 30, 2025. For more information, see https://azure.microsoft.com/updates/upgrade-to-standard-sku-public-ip-addresses-in-azure-by-30-september-2025-basic-sku-will-be-retired/" | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this part is relevant given this date has passed
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||||||
|
|
||||||
| func isPublicIPBasicSkuDeprecatedForCreation() bool { | ||||||
| losAngelesLocation, err := time.LoadLocation("America/Los_Angeles") | ||||||
| if err != nil { | ||||||
| losAngelesLocation = time.UTC | ||||||
| } | ||||||
|
|
||||||
| deprecationTime := time.Date(2025, time.April, 1, 0, 0, 0, 0, losAngelesLocation) | ||||||
| now := time.Now() | ||||||
| return now.After(deprecationTime.In(now.Location())) | ||||||
| } | ||||||
|
|
||||||
| func resourcePublicIpCreate(d *pluginsdk.ResourceData, meta interface{}) error { | ||||||
| client := meta.(*clients.Client).Network.PublicIPAddresses | ||||||
| subscriptionId := meta.(*clients.Client).Account.SubscriptionId | ||||||
|
|
||||||
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.
Making this O+C breaks the existing behaviour of replacing the resource when a user removes zones from their deployment (when sku is
Standard). We should try to keep this behaviour intact and we could use a DiffSuppressFunc instead.Additionally, O+C doesn't entirely resolve the
zonesdiff, currently a user could specify zones forStandardV2in config (e.g.zones = ["1"]) which would lead to a perpetual diff, we should prevent users from settingzonesonStandardV2with a CustomizeDiffe.g.
DiffSuppress:
CustomizeDiff:
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.
Make sense, code updated.