-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
New Resource: azurerm_data_lake_store #1219
Changes from 20 commits
a7a4050
9b4590c
0f434d8
6d3c508
d50f52a
56e9a01
dd3022f
5ef2472
242dfcc
7e430a4
4c487a1
16c79f2
0046546
0eb9490
e0722f1
fe30e5d
b663c43
1641e01
3d4c9f8
915a968
d014b3a
9bc6096
8d74125
59dee53
36e3882
47bb571
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
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, | ||
Optional: true, | ||
Default: false, | ||
}, | ||
|
||
"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("") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a warning message here that it wasn't found? Something like... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done, in next commit |
||
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 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
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), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we also check to make sure that
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in next commit |
||
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" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we formate the terraform in all the tests?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved to 2 spaces (I think thats what I think that means) |
||
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) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,7 @@ func Provider() terraform.ResourceProvider { | |
"azurerm_cdn_profile": dataSourceArmCdnProfile(), | ||
"azurerm_client_config": dataSourceArmClientConfig(), | ||
"azurerm_cosmosdb_account": dataSourceArmCosmosDBAccount(), | ||
"azurerm_data_lake_store": dataSourceArmDataLakeStoreAccount(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor: alphabetically this should be above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved, in next commit |
||
"azurerm_dns_zone": dataSourceArmDnsZone(), | ||
"azurerm_eventhub_namespace": dataSourceEventHubNamespace(), | ||
"azurerm_image": dataSourceArmImage(), | ||
|
@@ -130,6 +131,7 @@ func Provider() terraform.ResourceProvider { | |
"azurerm_container_service": resourceArmContainerService(), | ||
"azurerm_container_group": resourceArmContainerGroup(), | ||
"azurerm_cosmosdb_account": resourceArmCosmosDBAccount(), | ||
"azurerm_data_lake_store": resourceArmDataLakeStore(), | ||
"azurerm_dns_a_record": resourceArmDnsARecord(), | ||
"azurerm_dns_aaaa_record": resourceArmDnsAAAARecord(), | ||
"azurerm_dns_cname_record": resourceArmDnsCNameRecord(), | ||
|
@@ -330,6 +332,7 @@ func determineAzureResourceProvidersToRegister(providerList []resources.Provider | |
"Microsoft.ContainerInstance": {}, | ||
"Microsoft.ContainerRegistry": {}, | ||
"Microsoft.ContainerService": {}, | ||
"Microsoft.DataLakeStore": {}, | ||
"Microsoft.DBforMySQL": {}, | ||
"Microsoft.DBforPostgreSQL": {}, | ||
"Microsoft.Devices": {}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should be
computed
with no default?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup has to be computed