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_stream_analytics_reference_input_blob: Make storage_account_key optional when MSI auth is used #19676

Merged
merged 7 commits into from
Jan 5, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
normalize account key
  • Loading branch information
alxy committed Dec 14, 2022
commit ee423bfad8baf941c57206835bc73e6f07aa724a
2 changes: 1 addition & 1 deletion examples/stream-analytics/msi-auth/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Azure Stream Analytics: MSI authentication

This example provisions an example that uses MSI authentication for the Stream Analytics inputs and outputs.
This example provisions an example that uses [MSI authentication](https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview) for the Stream Analytics inputs and outputs.

## Inputs

1 change: 0 additions & 1 deletion examples/stream-analytics/msi-auth/main.tf
Original file line number Diff line number Diff line change
@@ -59,7 +59,6 @@ resource "azurerm_stream_analytics_reference_input_blob" "test" {
stream_analytics_job_name = "${azurerm_stream_analytics_job.example.name}"
resource_group_name = "${azurerm_stream_analytics_job.example.resource_group_name}"
storage_account_name = "${azurerm_storage_account.example.name}"
storage_account_key = "${azurerm_storage_account.example.primary_access_key}"
storage_container_name = "${azurerm_storage_container.example.name}"
authentication_mode = "Msi"
path_pattern = "some-random-pattern"
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ func resourceStreamAnalyticsReferenceInputBlob() *pluginsdk.Resource {

"storage_account_key": {
Type: pluginsdk.TypeString,
Required: true,
Optional: true,
Sensitive: true,
ValidateFunc: validation.StringIsNotEmpty,
},
@@ -149,7 +149,7 @@ func resourceStreamAnalyticsReferenceInputBlobCreate(d *pluginsdk.ResourceData,
StorageAccounts: &[]inputs.StorageAccount{
{
AccountName: utils.String(d.Get("storage_account_name").(string)),
AccountKey: utils.String(d.Get("storage_account_key").(string)),
AccountKey: normalizeAccountKey(d.Get("storage_account_key").(string)),
},
},
AuthenticationMode: utils.ToPtr(inputs.AuthenticationMode(d.Get("authentication_mode").(string))),
@@ -198,7 +198,7 @@ func resourceStreamAnalyticsReferenceInputBlobUpdate(d *pluginsdk.ResourceData,
StorageAccounts: &[]inputs.StorageAccount{
{
AccountName: utils.String(d.Get("storage_account_name").(string)),
AccountKey: utils.String(d.Get("storage_account_key").(string)),
AccountKey: normalizeAccountKey(d.Get("storage_account_key").(string)),
},
},
AuthenticationMode: utils.ToPtr(inputs.AuthenticationMode(d.Get("authentication_mode").(string))),
@@ -321,3 +321,11 @@ func resourceStreamAnalyticsReferenceInputBlobDelete(d *pluginsdk.ResourceData,

return nil
}

func normalizeAccountKey(accountKey string) *string {
if accountKey != "" {
return utils.String(accountKey)
}

return nil
}
Original file line number Diff line number Diff line change
@@ -85,10 +85,11 @@ func TestAccStreamAnalyticsReferenceInputBlob_update(t *testing.T) {
func TestAccStreamAnalyticsReferenceInputBlob_authenticationMode(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_stream_analytics_reference_input_blob", "test")
r := StreamAnalyticsReferenceInputBlobResource{}
debug := r.authenticationMode(data)

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.authenticationMode(data),
Config: debug,
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
@@ -247,7 +248,6 @@ resource "azurerm_stream_analytics_reference_input_blob" "test" {
stream_analytics_job_name = azurerm_stream_analytics_job.test.name
resource_group_name = azurerm_stream_analytics_job.test.resource_group_name
storage_account_name = azurerm_storage_account.test.name
storage_account_key = azurerm_storage_account.test.primary_access_key
storage_container_name = azurerm_storage_container.test.name
path_pattern = "some-random-pattern"
date_format = "yyyy/MM/dd"
@@ -300,11 +300,12 @@ resource "azurerm_resource_group" "test" {
}

resource "azurerm_storage_account" "test" {
name = "acctestsa%s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_tier = "Standard"
account_replication_type = "LRS"
name = "acctestsa%s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_tier = "Standard"
account_replication_type = "LRS"
allow_nested_items_to_be_public = false
}

resource "azurerm_storage_container" "test" {
@@ -317,7 +318,7 @@ resource "azurerm_stream_analytics_job" "test" {
name = "acctestjob-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
compatibility_level = "1.0"
compatibility_level = "1.1"
data_locale = "en-GB"
events_late_arrival_max_delay_in_seconds = 60
events_out_of_order_max_delay_in_seconds = 50