-
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
azurerm_eventhub_namespace
: support latest released properties:local_authentication_enabled
,public_network_access_enabled
,minimum_tls_version
#17194
Changes from 11 commits
4a3522f
8ebbf20
d7d9ef8
5e54c3f
f90ceca
493d4a1
12fb092
82c6692
f3a2326
22dd40d
f5b64e6
071027c
3a6c0cf
dd68bb1
bc96c79
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 |
---|---|---|
|
@@ -16,8 +16,8 @@ import ( | |
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags" | ||
"github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2021-11-01/authorizationrulesnamespaces" | ||
"github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2021-11-01/eventhubsclusters" | ||
"github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2021-11-01/namespaces" | ||
"github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2021-11-01/networkrulesets" | ||
"github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2022-01-01-preview/namespaces" | ||
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure" | ||
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/clients" | ||
|
@@ -190,6 +190,29 @@ func resourceEventHubNamespace() *pluginsdk.Resource { | |
}, | ||
}, | ||
|
||
"local_authentication_enabled": { | ||
Type: pluginsdk.TypeBool, | ||
Optional: true, | ||
Default: true, | ||
}, | ||
|
||
"minimum_tls_version": { | ||
Type: pluginsdk.TypeString, | ||
Optional: true, | ||
Default: string(namespaces.TlsVersionOnePointTwo), | ||
ValidateFunc: validation.StringInSlice([]string{ | ||
string(namespaces.TlsVersionOnePointZero), | ||
string(namespaces.TlsVersionOnePointOne), | ||
string(namespaces.TlsVersionOnePointTwo), | ||
}, false), | ||
}, | ||
|
||
"public_network_access_enabled": { | ||
Type: pluginsdk.TypeBool, | ||
Optional: true, | ||
Default: true, | ||
}, | ||
|
||
"default_primary_connection_string_alias": { | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
|
@@ -278,6 +301,13 @@ func resourceEventHubNamespaceCreate(d *pluginsdk.ResourceData, meta interface{} | |
return fmt.Errorf("expanding `identity`: %+v", err) | ||
} | ||
|
||
publicNetworkEnabled := namespaces.PublicNetworkAccessEnabled | ||
if !d.Get("public_network_access_enabled").(bool) { | ||
publicNetworkEnabled = namespaces.PublicNetworkAccessDisabled | ||
} | ||
|
||
miniTlsVersion := namespaces.TlsVersion(d.Get("minimum_tls_version").(string)) | ||
|
||
parameters := namespaces.EHNamespace{ | ||
Location: &location, | ||
Sku: &namespaces.Sku{ | ||
|
@@ -292,6 +322,9 @@ func resourceEventHubNamespaceCreate(d *pluginsdk.ResourceData, meta interface{} | |
Properties: &namespaces.EHNamespaceProperties{ | ||
IsAutoInflateEnabled: utils.Bool(autoInflateEnabled), | ||
ZoneRedundant: utils.Bool(zoneRedundant), | ||
DisableLocalAuth: utils.Bool(!d.Get("local_authentication_enabled").(bool)), | ||
PublicNetworkAccess: &publicNetworkEnabled, | ||
MinimumTlsVersion: &miniTlsVersion, | ||
}, | ||
Tags: tags.Expand(t), | ||
} | ||
|
@@ -346,6 +379,11 @@ func resourceEventHubNamespaceUpdate(d *pluginsdk.ResourceData, meta interface{} | |
t := d.Get("tags").(map[string]interface{}) | ||
autoInflateEnabled := d.Get("auto_inflate_enabled").(bool) | ||
zoneRedundant := d.Get("zone_redundant").(bool) | ||
publicNetworkEnabled := namespaces.PublicNetworkAccessEnabled | ||
if !d.Get("public_network_access_enabled").(bool) { | ||
publicNetworkEnabled = namespaces.PublicNetworkAccessDisabled | ||
} | ||
miniTlsVersion := namespaces.TlsVersion(d.Get("minimum_tls_version").(string)) | ||
|
||
identity, err := identity.ExpandSystemAndUserAssignedMap(d.Get("identity").([]interface{})) | ||
if err != nil { | ||
|
@@ -366,6 +404,9 @@ func resourceEventHubNamespaceUpdate(d *pluginsdk.ResourceData, meta interface{} | |
Properties: &namespaces.EHNamespaceProperties{ | ||
IsAutoInflateEnabled: utils.Bool(autoInflateEnabled), | ||
ZoneRedundant: utils.Bool(zoneRedundant), | ||
DisableLocalAuth: utils.Bool(!d.Get("local_authentication_enabled").(bool)), | ||
PublicNetworkAccess: &publicNetworkEnabled, | ||
MinimumTlsVersion: &miniTlsVersion, | ||
}, | ||
Tags: tags.Expand(t), | ||
} | ||
|
@@ -471,6 +512,16 @@ func resourceEventHubNamespaceRead(d *pluginsdk.ResourceData, meta interface{}) | |
d.Set("maximum_throughput_units", int(*props.MaximumThroughputUnits)) | ||
d.Set("zone_redundant", props.ZoneRedundant) | ||
d.Set("dedicated_cluster_id", props.ClusterArmId) | ||
if props.DisableLocalAuth != nil { | ||
localAuthEnable := *props.DisableLocalAuth | ||
d.Set("local_authentication_enabled", !localAuthEnable) | ||
} | ||
if props.PublicNetworkAccess != nil { | ||
d.Set("public_network_access_enabled", *props.PublicNetworkAccess == namespaces.PublicNetworkAccessEnabled) | ||
} | ||
if props.MinimumTlsVersion != nil { | ||
d.Set("minimum_tls_version", *props.MinimumTlsVersion) | ||
} | ||
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. all 3 of these fields need to be set all of the time, with a default value if they're not returned e.g.
|
||
} | ||
|
||
if err := tags.FlattenAndSet(d, model.Tags); err != nil { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 this also the default state the API returns when provisioning on an older version and upgrading to a newer api version?
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.
yes, I tried the older version and the default value is the same