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

Add signed_version attribute to azurerm_storage_account_sas #8020

Merged
Merged
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 @@ -39,6 +39,12 @@ func dataSourceArmStorageAccountSharedAccessSignature() *schema.Resource {
Default: true,
},

"signed_version": {
Type: schema.TypeString,
Optional: true,
Default: sasSignedVersion,
},

"resource_types": {
Type: schema.TypeList,
Required: true,
Expand Down Expand Up @@ -167,6 +173,7 @@ func dataSourceArmStorageAccountSharedAccessSignature() *schema.Resource {
func dataSourceArmStorageAccountSasRead(d *schema.ResourceData, _ interface{}) error {
connString := d.Get("connection_string").(string)
httpsOnly := d.Get("https_only").(bool)
signedVersion := d.Get("signed_version").(string)
resourceTypesIface := d.Get("resource_types").([]interface{})
servicesIface := d.Get("services").([]interface{})
start := d.Get("start").(string)
Expand Down Expand Up @@ -194,7 +201,6 @@ func dataSourceArmStorageAccountSasRead(d *schema.ResourceData, _ interface{}) e
signedProtocol = "https"
}
signedIp := ""
signedVersion := sasSignedVersion

sasToken, err := storage.ComputeAccountSASToken(accountName, accountKey, permissions, services, resourceTypes,
start, expiry, signedProtocol, signedIp, signedVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func TestAccDataSourceArmStorageAccountSas_basic(t *testing.T) {
Config: testAccDataSourceAzureRMStorageAccountSas_basic(data, startDate, endDate),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(data.ResourceName, "https_only", "true"),
resource.TestCheckResourceAttr(data.ResourceName, "signed_version", "2019-10-10"),
resource.TestCheckResourceAttr(data.ResourceName, "start", startDate),
resource.TestCheckResourceAttr(data.ResourceName, "expiry", endDate),
resource.TestCheckResourceAttrSet(data.ResourceName, "sas"),
Expand Down Expand Up @@ -61,6 +62,7 @@ resource "azurerm_storage_account" "test" {
data "azurerm_storage_account_sas" "test" {
connection_string = azurerm_storage_account.test.primary_connection_string
https_only = true
signed_version = "2019-10-10"

resource_types {
service = true
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/storage_account_sas.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ resource "azurerm_storage_account" "example" {
data "azurerm_storage_account_sas" "example" {
connection_string = azurerm_storage_account.example.primary_connection_string
https_only = true
signed_version = "2017-07-29"

resource_types {
service = true
Expand Down Expand Up @@ -77,6 +78,7 @@ output "sas_url_query_string" {

* `connection_string` - The connection string for the storage account to which this SAS applies. Typically directly from the `primary_connection_string` attribute of a terraform created `azurerm_storage_account` resource.
* `https_only` - (Optional) Only permit `https` access. If `false`, both `http` and `https` are permitted. Defaults to `true`.
* `signed_version` - (Optional) Specifies the signed storage service version to use to authorize requests made with this account SAS. Defaults to `2017-07-29`.
* `resource_types` - A `resource_types` block as defined below.
* `services` - A `services` block as defined below.
* `start` - The starting time and date of validity of this SAS. Must be a valid ISO-8601 format time/date string.
Expand Down