-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1219 from paktek123/add-adls-accounts
New Resource: azurerm_data_lake_store
- Loading branch information
Showing
18 changed files
with
4,488 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package azurerm | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/hashicorp/terraform/helper/schema" | ||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" | ||
) | ||
|
||
func dataSourceArmDataLakeStoreAccount() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceArmDateLakeStoreAccountRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
|
||
"resource_group_name": resourceGroupNameForDataSourceSchema(), | ||
|
||
"location": locationForDataSourceSchema(), | ||
|
||
"tier": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"tags": tagsForDataSourceSchema(), | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceArmDateLakeStoreAccountRead(d *schema.ResourceData, meta interface{}) error { | ||
client := meta.(*ArmClient).dataLakeStoreAccountClient | ||
ctx := meta.(*ArmClient).StopContext | ||
|
||
name := d.Get("name").(string) | ||
resourceGroup := d.Get("resource_group_name").(string) | ||
|
||
resp, err := client.Get(ctx, resourceGroup, name) | ||
if err != nil { | ||
if utils.ResponseWasNotFound(resp.Response) { | ||
log.Printf("[WARN] DataLakeStoreAccount '%s' was not found (resource group '%s')", name, resourceGroup) | ||
d.SetId("") | ||
return nil | ||
} | ||
return fmt.Errorf("Error making Read request on Azure Data Lake %q (Resource Group %q): %+v", name, resourceGroup, err) | ||
} | ||
|
||
d.SetId(*resp.ID) | ||
|
||
d.Set("name", name) | ||
d.Set("resource_group_name", resourceGroup) | ||
if location := resp.Location; location != nil { | ||
d.Set("location", azureRMNormalizeLocation(*location)) | ||
} | ||
|
||
if properties := resp.DataLakeStoreAccountProperties; properties != nil { | ||
d.Set("tier", string(properties.CurrentTier)) | ||
} | ||
|
||
flattenAndSetTags(d, resp.Tags) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package azurerm | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform/helper/acctest" | ||
"github.com/hashicorp/terraform/helper/resource" | ||
) | ||
|
||
func TestAccDataSourceAzureRMDataLakeStore_basic(t *testing.T) { | ||
dataSourceName := "data.azurerm_data_lake_store.test" | ||
rInt := acctest.RandInt() | ||
rs := acctest.RandString(4) | ||
location := testLocation() | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataSourceDataLakeStore_basic(rInt, rs, location), | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMDataLakeStoreExists(dataSourceName), | ||
resource.TestCheckResourceAttr(dataSourceName, "tier", "Consumption"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccDataSourceAzureRMDataLakeStore_tier(t *testing.T) { | ||
dataSourceName := "data.azurerm_data_lake_store.test" | ||
rInt := acctest.RandInt() | ||
rs := acctest.RandString(4) | ||
location := testLocation() | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataSourceDataLakeStore_tier(rInt, rs, location), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr(dataSourceName, "tier", "Commitment_1TB"), | ||
resource.TestCheckResourceAttr(dataSourceName, "tags.%", "1"), | ||
resource.TestCheckResourceAttr(dataSourceName, "tags.hello", "world"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDataSourceDataLakeStore_basic(rInt int, rs string, location string) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG_%d" | ||
location = "%s" | ||
} | ||
resource "azurerm_data_lake_store" "test" { | ||
name = "unlikely23exst2acct%s" | ||
location = "%s" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
} | ||
data "azurerm_data_lake_store" "test" { | ||
name = "${azurerm_data_lake_store.test.name}" | ||
resource_group_name = "${azurerm_data_lake_store.test.resource_group_name}" | ||
} | ||
`, rInt, location, rs, location) | ||
} | ||
|
||
func testAccDataSourceDataLakeStore_tier(rInt int, rs string, location string) string { | ||
return fmt.Sprintf(` | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG_%d" | ||
location = "%s" | ||
} | ||
resource "azurerm_data_lake_store" "test" { | ||
name = "unlikely23exst2acct%s" | ||
location = "%s" | ||
tier = "Commitment_1TB" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
tags { | ||
hello = "world" | ||
} | ||
} | ||
data "azurerm_data_lake_store" "test" { | ||
name = "${azurerm_data_lake_store.test.name}" | ||
resource_group_name = "${azurerm_data_lake_store.test.resource_group_name}" | ||
} | ||
`, rInt, location, rs, location) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.