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_mssql_server -support public_network_access_enabled #6678

Merged
merged 3 commits into from Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 21 additions & 8 deletions azurerm/internal/services/mssql/resource_arm_mssql_server.go
Expand Up @@ -107,6 +107,12 @@ func resourceArmMsSqlServer() *schema.Resource {
},
},

"public_network_access_enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},

"extended_auditing_policy": helper.ExtendedAuditingSchema(),

"fully_qualified_domain_name": {
Expand Down Expand Up @@ -148,26 +154,32 @@ func resourceArmMsSqlServerCreateUpdate(d *schema.ResourceData, meta interface{}
}
}

parameters := sql.Server{
props := sql.Server{
Location: utils.String(location),
Tags: metadata,
ServerProperties: &sql.ServerProperties{
Version: utils.String(version),
AdministratorLogin: utils.String(adminUsername),
PublicNetworkAccess: sql.ServerPublicNetworkAccessEnabled,
},
}

if _, ok := d.GetOk("identity"); ok {
sqlServerIdentity := expandAzureRmSqlServerIdentity(d)
parameters.Identity = sqlServerIdentity
props.Identity = sqlServerIdentity
}

if v := d.Get("public_network_access_enabled"); !v.(bool) {
props.ServerProperties.PublicNetworkAccess = sql.ServerPublicNetworkAccessDisabled
}


katbyte marked this conversation as resolved.
Show resolved Hide resolved
if d.HasChange("administrator_login_password") {
adminPassword := d.Get("administrator_login_password").(string)
parameters.ServerProperties.AdministratorLoginPassword = utils.String(adminPassword)
props.ServerProperties.AdministratorLoginPassword = utils.String(adminPassword)
}

future, err := client.CreateOrUpdate(ctx, resGroup, name, parameters)
future, err := client.CreateOrUpdate(ctx, resGroup, name, props)
if err != nil {
return fmt.Errorf("Error issuing create/update request for SQL Server %q (Resource Group %q): %+v", name, resGroup, err)
}
Expand Down Expand Up @@ -242,10 +254,11 @@ func resourceArmMsSqlServerRead(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("Error setting `identity`: %+v", err)
}

if serverProperties := resp.ServerProperties; serverProperties != nil {
d.Set("version", serverProperties.Version)
d.Set("administrator_login", serverProperties.AdministratorLogin)
d.Set("fully_qualified_domain_name", serverProperties.FullyQualifiedDomainName)
if props := resp.ServerProperties; props != nil {
d.Set("version", props.Version)
d.Set("administrator_login", props.AdministratorLogin)
d.Set("fully_qualified_domain_name", props.FullyQualifiedDomainName)
d.Set("public_network_access_enabled", props.PublicNetworkAccess == sql.ServerPublicNetworkAccessEnabled)
}

connection, err := connectionClient.Get(ctx, resGroup, name)
Expand Down