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

azurerm_nginx_deployment - support for the automatic_upgrade_channel property #24867

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/services/nginx/nginx_deployment_data_source.go
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@ type DeploymentDataSourceModel struct {
FrontendPublic []FrontendPublic `tfschema:"frontend_public"`
FrontendPrivate []FrontendPrivate `tfschema:"frontend_private"`
NetworkInterface []NetworkInterface `tfschema:"network_interface"`
UpgradeChannel string `tfschema:"automatic_upgrade_channel"`
Tags map[string]string `tfschema:"tags"`
}

@@ -164,6 +165,11 @@ func (m DeploymentDataSource) Attributes() map[string]*pluginsdk.Schema {
},
},

"automatic_upgrade_channel": {
puneetsarna marked this conversation as resolved.
Show resolved Hide resolved
Type: pluginsdk.TypeString,
Computed: true,
},

"tags": commonschema.TagsDataSource(),
}
}
@@ -267,6 +273,10 @@ func (m DeploymentDataSource) Read() sdk.ResourceFunc {
if userProfile := props.UserProfile; userProfile != nil && userProfile.PreferredEmail != nil {
output.Email = pointer.ToString(props.UserProfile.PreferredEmail)
}

if props.AutoUpgradeProfile != nil {
output.UpgradeChannel = props.AutoUpgradeProfile.UpgradeChannel
}
}
}

Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ func TestAccNginxDeploymentDataSource_basic(t *testing.T) {
check.That(data.ResourceName).Key("capacity").Exists(),
check.That(data.ResourceName).Key("managed_resource_group").Exists(),
check.That(data.ResourceName).Key("ip_address").Exists(),
check.That(data.ResourceName).Key("automatic_upgrade_channel").Exists(),
),
},
})
28 changes: 28 additions & 0 deletions internal/services/nginx/nginx_deployment_resource.go
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ type DeploymentModel struct {
FrontendPublic []FrontendPublic `tfschema:"frontend_public"`
FrontendPrivate []FrontendPrivate `tfschema:"frontend_private"`
NetworkInterface []NetworkInterface `tfschema:"network_interface"`
UpgradeChannel string `tfschema:"automatic_upgrade_channel"`
Tags map[string]string `tfschema:"tags"`
}

@@ -194,6 +195,17 @@ func (m DeploymentResource) Arguments() map[string]*pluginsdk.Schema {
},
},

"automatic_upgrade_channel": {
Type: pluginsdk.TypeString,
Optional: true,
Default: "stable",
ValidateFunc: validation.StringInSlice(
[]string{
"stable",
"preview",
}, false),
},

"tags": commonschema.Tags(),
}
}
@@ -309,6 +321,12 @@ func (m DeploymentResource) Create() sdk.ResourceFunc {
}
}

if model.UpgradeChannel != "" {
prop.AutoUpgradeProfile = &nginxdeployment.AutoUpgradeProfile{
UpgradeChannel: model.UpgradeChannel,
}
}

req.Properties = prop

req.Identity, err = identity.ExpandSystemAndUserAssignedMapFromModel(model.Identity)
@@ -412,6 +430,10 @@ func (m DeploymentResource) Read() sdk.ResourceFunc {
output.Email = pointer.ToString(props.UserProfile.PreferredEmail)
}

if props.AutoUpgradeProfile != nil {
output.UpgradeChannel = props.AutoUpgradeProfile.UpgradeChannel
}

flattenedIdentity, err := identity.FlattenSystemAndUserAssignedMapToModel(model.Identity)
if err != nil {
return fmt.Errorf("flattening `identity`: %v", err)
@@ -481,6 +503,12 @@ func (m DeploymentResource) Update() sdk.ResourceFunc {
}
}

if meta.ResourceData.HasChange("automatic_upgrade_channel") {
req.Properties.AutoUpgradeProfile = &nginxdeployment.AutoUpgradeProfile{
UpgradeChannel: model.UpgradeChannel,
}
}

if err := client.DeploymentsUpdateThenPoll(ctx, *id, req); err != nil {
return fmt.Errorf("updating %s: %v", id, err)
}
11 changes: 6 additions & 5 deletions internal/services/nginx/nginx_deployment_resource_test.go
Original file line number Diff line number Diff line change
@@ -105,11 +105,12 @@ func (a DeploymentResource) basic(data acceptance.TestData) string {
%s

resource "azurerm_nginx_deployment" "test" {
name = "acctest-%[2]d"
resource_group_name = azurerm_resource_group.test.name
sku = "standard_Monthly"
location = azurerm_resource_group.test.location
diagnose_support_enabled = true
name = "acctest-%[2]d"
resource_group_name = azurerm_resource_group.test.name
sku = "standard_Monthly"
location = azurerm_resource_group.test.location
diagnose_support_enabled = true
automatic_upgrade_channel = "stable"

frontend_public {
ip_address = [azurerm_public_ip.test.id]
2 changes: 2 additions & 0 deletions website/docs/d/nginx_deployment.html.markdown
Original file line number Diff line number Diff line change
@@ -63,6 +63,8 @@ In addition to the Arguments listed above - the following Attributes are exporte

* `sku` - Name of the SKU for this Nginx Deployment.

* `automatic_upgrade_channel` - The automatic upgrade channel for this NGINX deployment.

* `tags` - A mapping of tags assigned to the Nginx Deployment.

---
15 changes: 9 additions & 6 deletions website/docs/r/nginx_deployment.html.markdown
Original file line number Diff line number Diff line change
@@ -55,12 +55,13 @@ resource "azurerm_subnet" "example" {
}

resource "azurerm_nginx_deployment" "example" {
name = "example-nginx"
resource_group_name = azurerm_resource_group.example.name
sku = "publicpreview_Monthly_gmz7xq9ge3py"
location = azurerm_resource_group.example.location
managed_resource_group = "example"
diagnose_support_enabled = true
name = "example-nginx"
resource_group_name = azurerm_resource_group.example.name
sku = "publicpreview_Monthly_gmz7xq9ge3py"
location = azurerm_resource_group.example.location
managed_resource_group = "example"
diagnose_support_enabled = true
automatic_upgrade_channel = "stable"

frontend_public {
ip_address = [azurerm_public_ip.example.id]
@@ -109,6 +110,8 @@ The following arguments are supported:

* `network_interface` - (Optional) One or more `network_interface` blocks as defined below. Changing this forces a new Nginx Deployment to be created.

* `automatic_upgrade_channel` - (Optional) Specify the automatic upgrade channel for the NGINX deployment. Defaults to `stable`. The possible values are `stable` and `preview`.

* `tags` - (Optional) A mapping of tags which should be assigned to the Nginx Deployment.

---