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_stream_input_blob: support for authentication_mode #27853

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"log"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-sdk/resource-manager/streamanalytics/2020-03-01/inputs"
Expand Down Expand Up @@ -98,6 +99,16 @@ func resourceStreamAnalyticsStreamInputBlob() *pluginsdk.Resource {
},

"serialization": schemaStreamAnalyticsStreamInputSerialization(),

"authentication_mode": {
Type: pluginsdk.TypeString,
Optional: true,
Default: string(inputs.AuthenticationModeConnectionString),
ValidateFunc: validation.StringInSlice([]string{
string(inputs.AuthenticationModeConnectionString),
string(inputs.AuthenticationModeMsi),
}, false),
},
},
}
}
Expand Down Expand Up @@ -154,6 +165,7 @@ func resourceStreamAnalyticsStreamInputBlobCreateUpdate(d *pluginsdk.ResourceDat
AccountKey: utils.String(storageAccountKey),
},
},
AuthenticationMode: pointer.To(inputs.AuthenticationMode(d.Get("authentication_mode").(string))),
},
},
Serialization: serialization,
Expand Down Expand Up @@ -242,6 +254,12 @@ func resourceStreamAnalyticsStreamInputBlobRead(d *pluginsdk.ResourceData, meta
}
d.Set("time_format", timeFormat)

authMode := ""
if v := streamBlobInputProps.AuthenticationMode; v != nil {
authMode = string(*v)
}
d.Set("authentication_mode", authMode)

if accounts := streamBlobInputProps.StorageAccounts; accounts != nil && len(*accounts) > 0 {
account := (*accounts)[0]
d.Set("storage_account_name", account.AccountName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ func TestAccStreamAnalyticsStreamInputBlob_update(t *testing.T) {
})
}

func TestAccStreamAnalyticsStreamInputBlob_authenticationMode(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_stream_analytics_stream_input_blob", "test")
r := StreamAnalyticsStreamInputBlobResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.authenticationMode(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("storage_account_key"),
})
}

func TestAccStreamAnalyticsStreamInputBlob_requiresImport(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_stream_analytics_stream_input_blob", "test")
r := StreamAnalyticsStreamInputBlobResource{}
Expand Down Expand Up @@ -225,6 +240,31 @@ resource "azurerm_stream_analytics_stream_input_blob" "test" {
`, template, data.RandomString, data.RandomInteger)
}

func (r StreamAnalyticsStreamInputBlobResource) authenticationMode(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
%s

resource "azurerm_stream_analytics_stream_input_blob" "test" {
name = "acctestinput-%d"
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"
time_format = "HH"
authentication_mode = "Msi"

serialization {
type = "Json"
encoding = "UTF8"
}
}
`, template, data.RandomInteger)
}

func (r StreamAnalyticsStreamInputBlobResource) requiresImport(data acceptance.TestData) string {
template := r.json(data)
return fmt.Sprintf(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ The following arguments are supported:

* `serialization` - (Required) A `serialization` block as defined below.

* `authentication_mode` - (Optional) The authentication mode for the Stream Analytics Input. Possible values are `Msi` and `ConnectionString`. Defaults to `ConnectionString`.

---

A `serialization` block supports the following:
Expand Down
Loading