Skip to content

Commit

Permalink
Merge pull request #3 from terraform-providers/master
Browse files Browse the repository at this point in the history
sync from head
  • Loading branch information
ghostinthewires authored Feb 18, 2019
2 parents ef2592a + f3da508 commit f63dc24
Show file tree
Hide file tree
Showing 68 changed files with 3,796 additions and 776 deletions.
26 changes: 24 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
## 1.22.1 (Unreleased)
## 1.23.0 (Unreleased)

FEATURES:

* **New Data Source:** `azurerm_availability_set` [GH-2850]

IMPROVEMENTS:

* dependencies: upgrading to v25.1.0 of `github.com/Azure/azure-sdk-for-go` [GH-2886]
* dependencies: upgrading to v11.4.0 of `github.com/Azure/go-autorest` [GH-2886]
* `azurerm_application_gateway` - support for `path` within the `backend_http_settings` block [GH-2879]
* `azurerm_redis_cache` - support for configuring the `maxfragmentationmemory_reserved` in the `redis_configuration` block [GH-2887]

BUG FIXES:

* `azurerm_batch_pool` - updating `max_tasks_per_node` to be ForceNew [GH-2856]
* `azurerm_redis_firewall_rule` - allowing underscores in the `name` field [GH-2906]

## 1.22.1 (February 14, 2019)

BUG FIXES:

* `azurerm_storage_container` - support for large numbers of containers within a storage account [GH-2873]
* `azurerm_key_vault_access_policy` - will no longer fail to find the Key Vault if `key_vault_id` is empty ([#2874](https://github.com/terraform-providers/terraform-provider-azurerm/issues/2874))
* `azurerm_key_vault_certificate` - will no longer fail to find the Key Vault if `key_vault_id` is ([#2874](https://github.com/terraform-providers/terraform-provider-azurerm/issues/2874))
* `azurerm_key_vault_key` - will no longer fail to find the Key Vault if `key_vault_id` is ([#2874](https://github.com/terraform-providers/terraform-provider-azurerm/issues/2874))
* `azurerm_key_vault_secret` - will no longer fail to find the Key Vault if `key_vault_id` is ([#2874](https://github.com/terraform-providers/terraform-provider-azurerm/issues/2874))
* `azurerm_storage_container` - support for large numbers of containers within a storage account ([#2873](https://github.com/terraform-providers/terraform-provider-azurerm/issues/2873))

## 1.22.0 (February 11, 2019)

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,9 @@ The following Environment Variables must be set in your shell prior to running a
- `ARM_TEST_LOCATION_ALT`

**Note:** Acceptance tests create real resources in Azure which often cost money to run.

Crosscompiling
--------------
```sh
GOOS=windows GOARCH=amd64 make build
```
79 changes: 79 additions & 0 deletions azurerm/data_source_availability_set.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package azurerm

import (
"fmt"
"strings"

"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

func dataSourceArmAvailabilitySet() *schema.Resource {
return &schema.Resource{
Read: dataSourceArmAvailabilitySetRead,
Schema: map[string]*schema.Schema{
"resource_group_name": resourceGroupNameForDataSourceSchema(),

"name": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validate.NoEmptyStrings,
},

"location": {
Type: schema.TypeString,
Computed: true,
},

"platform_update_domain_count": {
Type: schema.TypeString,
Computed: true,
},

"platform_fault_domain_count": {
Type: schema.TypeString,
Computed: true,
},

"managed": {
Type: schema.TypeBool,
Computed: true,
},

"tags": tagsForDataSourceSchema(),
},
}
}

func dataSourceArmAvailabilitySetRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).availSetClient
ctx := meta.(*ArmClient).StopContext

resGroup := d.Get("resource_group_name").(string)
name := d.Get("name").(string)

resp, err := client.Get(ctx, resGroup, name)
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
return fmt.Errorf("Error: Availability Set %q (Resource Group %q) was not found", name, resGroup)
}

return fmt.Errorf("Error making Read request on Availability Set %q (Resource Group %q): %+v", name, resGroup, err)
}

d.SetId(*resp.ID)
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}
if resp.Sku != nil && resp.Sku.Name != nil {
d.Set("managed", strings.EqualFold(*resp.Sku.Name, "Aligned"))
}
if props := resp.AvailabilitySetProperties; props != nil {
d.Set("platform_update_domain_count", props.PlatformUpdateDomainCount)
d.Set("platform_fault_domain_count", props.PlatformFaultDomainCount)
}
flattenAndSetTags(d, resp.Tags)

return nil
}
56 changes: 56 additions & 0 deletions azurerm/data_source_availability_set_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package azurerm

import (
"fmt"
"testing"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"

"github.com/hashicorp/terraform/helper/resource"
)

func TestAccDataSourceAvailabilitySet_basic(t *testing.T) {
dataSourceName := "data.azurerm_availability_set.test"
ri := tf.AccRandTimeInt()
location := testLocation()

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceAvailabilitySet_basic(ri, location),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(dataSourceName, "location"),
resource.TestCheckResourceAttrSet(dataSourceName, "name"),
resource.TestCheckResourceAttrSet(dataSourceName, "resource_group_name"),
resource.TestCheckResourceAttr(dataSourceName, "tags.%", "1"),
),
},
},
})
}

func testAccDataSourceAvailabilitySet_basic(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%[1]d"
location = "%[2]s"
}
resource "azurerm_availability_set" "test" {
name = "acctestavset-%[1]d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
tags {
"foo" = "bar"
}
}
data "azurerm_availability_set" "test" {
resource_group_name = "${azurerm_resource_group.test.name}"
name = "${azurerm_availability_set.test.name}"
}
`, rInt, location)
}
5 changes: 4 additions & 1 deletion azurerm/data_source_key_vault_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ func dataSourceArmKeyVaultKeyRead(d *schema.ResourceData, meta interface{}) erro
} else {
id, err := azure.GetKeyVaultIDFromBaseUrl(ctx, vaultClient, keyVaultBaseUri)
if err != nil {
return fmt.Errorf("Error unable to find key vault ID from URL %q for certificate %q: %+v", keyVaultBaseUri, name, err)
return fmt.Errorf("Error retrieving the Resource ID the Key Vault at URL %q: %s", keyVaultBaseUri, err)
}
if id == nil {
return fmt.Errorf("Unable to locate the Resource ID for the Key Vault at URL %q: %s", keyVaultBaseUri, err)
}
d.Set("key_vault_id", id)
}
Expand Down
6 changes: 5 additions & 1 deletion azurerm/data_source_key_vault_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ func dataSourceArmKeyVaultSecretRead(d *schema.ResourceData, meta interface{}) e
} else {
id, err := azure.GetKeyVaultIDFromBaseUrl(ctx, vaultClient, keyVaultBaseUri)
if err != nil {
return fmt.Errorf("Error unable to find key vault ID from URL %q for certificate %q: %+v", keyVaultBaseUri, name, err)
return fmt.Errorf("Error retrieving the Resource ID the Key Vault at URL %q: %s", keyVaultBaseUri, err)
}
if id == nil {
return fmt.Errorf("Unable to locate the Resource ID for the Key Vault at URL %q: %s", keyVaultBaseUri, err)
}

d.Set("key_vault_id", id)
}

Expand Down
38 changes: 19 additions & 19 deletions azurerm/helpers/azure/key_vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package azure
import (
"context"
"fmt"
"log"

"github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2018-02-14/keyvault"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)
Expand Down Expand Up @@ -41,51 +39,53 @@ func GetKeyVaultBaseUrlFromID(ctx context.Context, client keyvault.VaultsClient,
return *resp.Properties.VaultURI, nil
}

func GetKeyVaultIDFromBaseUrl(ctx context.Context, client keyvault.VaultsClient, keyVaultUrl string) (string, error) {

func GetKeyVaultIDFromBaseUrl(ctx context.Context, client keyvault.VaultsClient, keyVaultUrl string) (*string, error) {
list, err := client.ListComplete(ctx, utils.Int32(1000))
if err != nil {
return "", fmt.Errorf("Error GetKeyVaultId unable to list Key Vaults %v", err)
return nil, fmt.Errorf("Error GetKeyVaultId unable to list Key Vaults %v", err)
}

for list.NotDone() {
v := list.Value()

if v.ID == nil {
log.Printf("[DEBUG]GetKeyVaultId: v.ID was nil, continuing")
continue
return nil, fmt.Errorf("v.ID was nil")
}

vid, err := ParseAzureResourceID(*v.ID)
if err != nil {
log.Printf("[DEBUG] GetKeyVaultId: unable to parse v.ID (%s): %v", *v.ID, err)
continue
return nil, fmt.Errorf("Error parsing ID for Key Vault URI %q: %s", *v.ID, err)
}
resourceGroup := vid.ResourceGroup
name := vid.Path["vaults"]

//resp does not appear to contain the vault properties, so lets fech them
//resp does not appear to contain the vault properties, so lets fetch them
get, err := client.Get(ctx, resourceGroup, name)
if err != nil {
log.Printf("[DEBUG] GetKeyVaultId: Error making Read request on KeyVault %q (Resource Group %q): %+v", name, resourceGroup, err)
continue
if utils.ResponseWasNotFound(get.Response) {
if e := list.NextWithContext(ctx); e != nil {
return nil, fmt.Errorf("Error getting next vault on KeyVault url %q : %+v", keyVaultUrl, err)
}
continue
}
return nil, fmt.Errorf("Error making Read request on KeyVault %q (Resource Group %q): %+v", name, resourceGroup, err)
}

if get.ID == nil || get.Properties == nil || get.Properties.VaultURI == nil {
log.Printf("[DEBUG] GetKeyVaultId: KeyVault %q (Resource Group %q) has nil ID, properties or vault URI", name, resourceGroup)
continue
return nil, fmt.Errorf("KeyVault %q (Resource Group %q) has nil ID, properties or vault URI", name, resourceGroup)
}

if keyVaultUrl == *get.Properties.VaultURI {
return *get.ID, nil
return get.ID, nil
}

e := list.NextWithContext(ctx)
if e != nil {
return "", fmt.Errorf("Error GetKeyVaultId: Error getting next value on KeyVault %q (Resource Group %q): %+v", name, resourceGroup, err)
if e := list.NextWithContext(ctx); e != nil {
return nil, fmt.Errorf("Error getting next vault on KeyVault url %q : %+v", keyVaultUrl, err)
}
}

return "", fmt.Errorf("Error GetKeyVaultId unable to find Key Vault with url %q", keyVaultUrl)
// we haven't found it, but Data Sources and Resources need to handle this error separately
return nil, nil
}

func KeyVaultExists(ctx context.Context, client keyvault.VaultsClient, keyVaultId string) (bool, error) {
Expand Down
1 change: 1 addition & 0 deletions azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func Provider() terraform.ResourceProvider {
"azurerm_app_service": dataSourceArmAppService(),
"azurerm_application_insights": dataSourceArmApplicationInsights(),
"azurerm_application_security_group": dataSourceArmApplicationSecurityGroup(),
"azurerm_availability_set": dataSourceArmAvailabilitySet(),
"azurerm_azuread_application": dataSourceArmAzureADApplication(),
"azurerm_azuread_service_principal": dataSourceArmActiveDirectoryServicePrincipal(),
"azurerm_batch_account": dataSourceArmBatchAccount(),
Expand Down
11 changes: 11 additions & 0 deletions azurerm/resource_arm_application_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ func resourceArmApplicationGateway() *schema.Resource {
Required: true,
},

"path": {
Type: schema.TypeString,
Optional: true,
},

"port": {
Type: schema.TypeInt,
Required: true,
Expand Down Expand Up @@ -1226,6 +1231,7 @@ func expandApplicationGatewayBackendHTTPSettings(d *schema.ResourceData, gateway
v := raw.(map[string]interface{})

name := v["name"].(string)
path := v["path"].(string)
port := int32(v["port"].(int))
protocol := v["protocol"].(string)
cookieBasedAffinity := v["cookie_based_affinity"].(string)
Expand All @@ -1236,6 +1242,7 @@ func expandApplicationGatewayBackendHTTPSettings(d *schema.ResourceData, gateway
Name: &name,
ApplicationGatewayBackendHTTPSettingsPropertiesFormat: &network.ApplicationGatewayBackendHTTPSettingsPropertiesFormat{
CookieBasedAffinity: network.ApplicationGatewayCookieBasedAffinity(cookieBasedAffinity),
Path: utils.String(path),
PickHostNameFromBackendAddress: utils.Bool(pickHostNameFromBackendAddress),
Port: utils.Int32(port),
Protocol: network.ApplicationGatewayProtocol(protocol),
Expand Down Expand Up @@ -1294,6 +1301,10 @@ func flattenApplicationGatewayBackendHTTPSettings(input *[]network.ApplicationGa

if props := v.ApplicationGatewayBackendHTTPSettingsPropertiesFormat; props != nil {
output["cookie_based_affinity"] = string(props.CookieBasedAffinity)

if path := props.Path; path != nil {
output["path"] = *path
}
if port := props.Port; port != nil {
output["port"] = int(*port)
}
Expand Down
Loading

0 comments on commit f63dc24

Please sign in to comment.