diff --git a/azurerm/config.go b/azurerm/config.go index 001ecffa95198..863c970065c4b 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -194,6 +194,13 @@ func getArmClient(authConfig *authentication.Config, skipProviderRegistration bo // Storage Endpoints storageAuth := authConfig.BearerAuthorizerCallback(sender, oauthConfig) + // Filesystem Endpoints + filesystemEndpoint := env.ResourceIdentifiers.Storage + filesystemAuth, err := authConfig.GetAuthorizationToken(sender, oauthConfig, filesystemEndpoint) + if err != nil { + return nil, err + } + // Key Vault Endpoints keyVaultAuth := authConfig.BearerAuthorizerCallback(sender, oauthConfig) @@ -207,6 +214,7 @@ func getArmClient(authConfig *authentication.Config, skipProviderRegistration bo ResourceManagerAuthorizer: auth, ResourceManagerEndpoint: endpoint, StorageAuthorizer: storageAuth, + FilesystemAuthorizer: filesystemAuth, PollingDuration: 180 * time.Minute, SkipProviderReg: skipProviderRegistration, DisableCorrelationRequestID: disableCorrelationRequestID, diff --git a/azurerm/internal/common/client_options.go b/azurerm/internal/common/client_options.go index fed2932e0ea31..40b95ead2394b 100644 --- a/azurerm/internal/common/client_options.go +++ b/azurerm/internal/common/client_options.go @@ -25,6 +25,7 @@ type ClientOptions struct { ResourceManagerAuthorizer autorest.Authorizer ResourceManagerEndpoint string StorageAuthorizer autorest.Authorizer + FilesystemAuthorizer autorest.Authorizer PollingDuration time.Duration SkipProviderReg bool diff --git a/azurerm/internal/services/storage/client.go b/azurerm/internal/services/storage/client.go index c8583a4c46626..e4a00c52af094 100644 --- a/azurerm/internal/services/storage/client.go +++ b/azurerm/internal/services/storage/client.go @@ -4,12 +4,15 @@ import ( "context" "fmt" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-04-01/storage" az "github.com/Azure/go-autorest/autorest/azure" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/authorizers" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" "github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/blobs" "github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/containers" + "github.com/tombuildsstuff/giovanni/storage/2018-11-09/datalakestore/filesystems" "github.com/tombuildsstuff/giovanni/storage/2018-11-09/file/directories" "github.com/tombuildsstuff/giovanni/storage/2018-11-09/file/shares" "github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/queues" @@ -18,7 +21,8 @@ import ( ) type Client struct { - AccountsClient storage.AccountsClient + AccountsClient storage.AccountsClient + FilesystemAuthorizer autorest.Authorizer environment az.Environment } @@ -30,8 +34,9 @@ func BuildClient(options *common.ClientOptions) *Client { // TODO: switch Storage Containers to using the storage.BlobContainersClient // (which should fix #2977) when the storage clients have been moved in here return &Client{ - AccountsClient: accountsClient, - environment: options.Environment, + AccountsClient: accountsClient, + FilesystemAuthorizer: options.FilesystemAuthorizer, + environment: options.Environment, } } @@ -59,6 +64,13 @@ func (client Client) ContainersClient(ctx context.Context, resourceGroup, accoun return &containersClient, nil } +func (client Client) FileSystemsClient(ctx context.Context, resourceGroup, accountName string) (*filesystems.Client, error) { + filesystemAuth := client.FilesystemAuthorizer + fileSystemsClient := filesystems.NewWithEnvironment(client.environment) + fileSystemsClient.Client.Authorizer = filesystemAuth + return &fileSystemsClient, nil +} + func (client Client) FileShareDirectoriesClient(ctx context.Context, resourceGroup, accountName string) (*directories.Client, error) { accountKey, err := client.findAccountKey(ctx, resourceGroup, accountName) if err != nil { diff --git a/azurerm/provider.go b/azurerm/provider.go index 23dc586df32eb..1e5c75307b977 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -418,6 +418,7 @@ func Provider() terraform.ResourceProvider { "azurerm_storage_share_directory": resourceArmStorageShareDirectory(), "azurerm_storage_table": resourceArmStorageTable(), "azurerm_storage_table_entity": resourceArmStorageTableEntity(), + "azurerm_storage_filesystem": resourceArmStorageFilesystem(), "azurerm_stream_analytics_job": resourceArmStreamAnalyticsJob(), "azurerm_stream_analytics_function_javascript_udf": resourceArmStreamAnalyticsFunctionUDF(), "azurerm_stream_analytics_output_blob": resourceArmStreamAnalyticsOutputBlob(), diff --git a/go.mod b/go.mod index 587092c926e97..7cd89e9576a51 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/satori/go.uuid v1.2.0 github.com/satori/uuid v0.0.0-20160927100844-b061729afc07 github.com/terraform-providers/terraform-provider-azuread v0.6.0 - github.com/tombuildsstuff/giovanni v0.5.0 + github.com/tombuildsstuff/giovanni v0.6.0 golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 golang.org/x/net v0.0.0-20190502183928-7f726cade0ab gopkg.in/yaml.v2 v2.2.2 diff --git a/go.sum b/go.sum index e07f01fa4babe..2f70190ad6d3d 100644 --- a/go.sum +++ b/go.sum @@ -489,6 +489,8 @@ github.com/terraform-providers/terraform-provider-openstack v1.15.0/go.mod h1:2a github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tombuildsstuff/giovanni v0.5.0 h1:ih4qTvjOOAHubTdINDWtrTpHyHNzrqam4xcIWQY9A1A= github.com/tombuildsstuff/giovanni v0.5.0/go.mod h1:Xu/XU+DiRrKTDoCnJNGuh9ysD0eJyi/zU/naFh2aN9I= +github.com/tombuildsstuff/giovanni v0.6.0 h1:8RwaDJJqbp8mMN/HOKEbGUvhW/yaGMzxN2XbkQ3lHuA= +github.com/tombuildsstuff/giovanni v0.6.0/go.mod h1:Xu/XU+DiRrKTDoCnJNGuh9ysD0eJyi/zU/naFh2aN9I= github.com/ugorji/go v0.0.0-20180813092308-00b869d2f4a5 h1:cMjKdf4PxEBN9K5HaD9UMW8gkTbM0kMzkTa9SJe0WNQ= github.com/ugorji/go v0.0.0-20180813092308-00b869d2f4a5/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 h1:3SVOIvH7Ae1KRYyQWRjXWJEA9sS/c/pjvH++55Gr648=