Skip to content

Commit

Permalink
Merge branch 'api-management' into api-management-api
Browse files Browse the repository at this point in the history
* api-management:
  Updating to include hashicorp#1565
  resource/servicebus_subscription_rule: Fix the correlation_filter optional values (hashicorp#1565)
  Updating to include hashicorp#1563
  resouce/app_insights: Allow different application_type deployments (hashicorp#1563)
  VMSS: changed sku property from a set to list
  Update CHANGELOG.md to include hashicorp#1552
  Renamed azurerm_azuread_application.html.markdown to azuread_application.html.markdown
  New Data Source: `azurerm_azuread_application`
  VMSS: Updating the code samples to be valid. Fixes hashicorp#1539 (hashicorp#1549)
  Creation Data -> Creation Date (hashicorp#1548)
  Updating to include hashicorp#1546
  Workaround upstream issue in creating azureEndpoints in traffic manager (hashicorp#1546)
  Cleanup after v1.9.0 release
  v1.9.0
  Updating to include hashicorp#1269
  New Resource: `azurerm_azuread_application` (hashicorp#1269)
  Remove tags validate in preConfig of TestAccAzureRMKeyVault_update (hashicorp#1534)
  Updating to include hashicorp#1535
  `azurerm_key_vault_key` - handling the parent Key Vault being deleted (hashicorp#1535)
  • Loading branch information
torresdal committed Jul 13, 2018
2 parents 8b0131e + 5d58d0d commit 2004c75
Show file tree
Hide file tree
Showing 27 changed files with 1,383 additions and 104 deletions.
72 changes: 43 additions & 29 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,55 @@
## 1.9.0 (Unreleased)
## 1.10.0 (Unreleased)

FEATURES:

* **New Resource:** `azurerm_data_lake_store_firewall_rule` [GH-1499]
* **New Resource:** `azurerm_key_vault_access_policy` [GH-1149]
* **New Resource:** `azurerm_scheduler_job` [GH-1172]
* **New Resource:** `azurerm_servicebus_namespace_authorization_rule` [GH-1498]
* **New Resource:** `azurerm_user_assigned_identity` [GH-1448]
* **New Data Source:** `azurerm_azuread_application` [GH-1552]

BUG FIXES:

* `azurerm_application_insights` - fixing a bug where `application_type` was set to `other` [GH-1563]
* `azurerm_servicebus_subscription` - only sending `correlation_filter` values if they're set [GH-1565]
* `azurerm_traffic_manager_endpoint` - working around a bug in the API by setting `target` to nil when a `target_resource_id` is specified [GH-1546]

## 1.9.0 (July 11, 2018)

FEATURES:

* **New Resource:** `azurerm_azuread_application` ([#1269](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1269))
* **New Resource:** `azurerm_data_lake_store_firewall_rule` ([#1499](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1499))
* **New Resource:** `azurerm_key_vault_access_policy` ([#1149](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1149))
* **New Resource:** `azurerm_scheduler_job` ([#1172](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1172))
* **New Resource:** `azurerm_servicebus_namespace_authorization_rule` ([#1498](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1498))
* **New Resource:** `azurerm_user_assigned_identity` ([#1448](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1448))

IMPROVEMENTS:

* dependencies: updating the `containerservice` SDK to `2018-03-31` to support AKS GA [GH-1474]
* dependencies: updating to `v18.0.0` of `Azure/azure-sdk-for-go` [GH-1487]
* dependencies: updating to `v10.12.0` of `Azure/go-autorest` [GH-1487]
* `azurerm_application_gateway` - adding `minimum_servers` to the probe resource [GH-1510]
* `azurerm_cdn_profile` - support for `Standard_ChinaCdn` and `Standard_Microsoft` SKU's [GH-1465]
* `azurerm_cosmosdb_account` - checking to see if the name is in use before creating [GH-1464]
* `azurerm_cosmosdb_account` - fixing the validation on the `ip_range_filter` field [GH-1463]
* `azurerm_dns_zone` - support for Private DNS Zones [GH-1404]
* `azurerm_image` - change os_disk property to a list and add addtional property validation [GH-1443]
* `azurerm_lb` - allow `private_ip_address` to be set to an empty value [GH-1481]
* `azurerm_mysql_server` - changing the `storage_mb` property no longer forces a new resource [GH-1532]
* `azurerm_postgresql_server` - changing the `storage_mb` property no longer forces a new resource [GH-1532]
* `azurerm_servicebus_queue` - `enable_partitioning` can now be enabled for `Basic` and `Standard` tiers [GH-1391]
* `azurerm_virtual_machine` - support for specifying user assigned identities [GH-1448]
* `azurerm_virtual_machine` - making the `content` field in the `additional_unattend_config` block (within `os_profile_windows_config`) sensitive [GH-1471]
* `azurerm_virtual_machine_data_disk_attachment` - adding support for `write_accelerator_enabled` [GH-1473]
* `azurerm_virtual_machine_scale_set` - ensuring we set the `vhd_containers` field to fix a crash [GH-1411]
* `azurerm_virtual_machine_scale_set` - support for specifying user assigned identities [GH-1448]
* `azurerm_virtual_machine_scale_set` - making the `content` field in the `additional_unattend_config` block (within `os_profile_windows_config`) sensitive [GH-1471]
* `azurerm_virtual_network_gateway` - adding support for the `radius_server_address`, `radius_server_secret` and `vpn_client_protocols` fields to the Data Source [GH-1505]
* dependencies: updating the `containerservice` SDK to `2018-03-31` to support AKS GA ([#1474](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1474))
* dependencies: updating to `v18.0.0` of `Azure/azure-sdk-for-go` ([#1487](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1487))
* dependencies: updating to `v10.12.0` of `Azure/go-autorest` ([#1487](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1487))
* `azurerm_application_gateway` - adding `minimum_servers` to the probe resource ([#1510](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1510))
* `azurerm_cdn_profile` - support for `Standard_ChinaCdn` and `Standard_Microsoft` SKU's ([#1465](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1465))
* `azurerm_cosmosdb_account` - checking to see if the name is in use before creating ([#1464](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1464))
* `azurerm_cosmosdb_account` - fixing the validation on the `ip_range_filter` field ([#1463](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1463))
* `azurerm_dns_zone` - support for Private DNS Zones ([#1404](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1404))
* `azurerm_image` - change os_disk property to a list and add addtional property validation ([#1443](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1443))
* `azurerm_lb` - allow `private_ip_address` to be set to an empty value ([#1481](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1481))
* `azurerm_mysql_server` - changing the `storage_mb` property no longer forces a new resource ([#1532](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1532))
* `azurerm_postgresql_server` - changing the `storage_mb` property no longer forces a new resource ([#1532](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1532))
* `azurerm_servicebus_queue` - `enable_partitioning` can now be enabled for `Basic` and `Standard` tiers ([#1391](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1391))
* `azurerm_virtual_machine` - support for specifying user assigned identities ([#1448](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1448))
* `azurerm_virtual_machine` - making the `content` field in the `additional_unattend_config` block (within `os_profile_windows_config`) sensitive ([#1471](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1471))
* `azurerm_virtual_machine_data_disk_attachment` - adding support for `write_accelerator_enabled` ([#1473](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1473))
* `azurerm_virtual_machine_scale_set` - ensuring we set the `vhd_containers` field to fix a crash ([#1411](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1411))
* `azurerm_virtual_machine_scale_set` - support for specifying user assigned identities ([#1448](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1448))
* `azurerm_virtual_machine_scale_set` - making the `content` field in the `additional_unattend_config` block (within `os_profile_windows_config`) sensitive ([#1471](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1471))
* `azurerm_virtual_network_gateway` - adding support for the `radius_server_address`, `radius_server_secret` and `vpn_client_protocols` fields to the Data Source ([#1505](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1505))

BUG FIXES:

* `azurerm_sql_database` - fix `requested_service_objective_name` updates [GH-1503]
* `azurerm_storage_account` - limiting the `tags` field to 128 characters to match the service [GH-1524]
* `azurerm_virtual_network_gateway` - fix `azurerm_virtual_network_gateway` crashing when `vpn_client_configuration` was not supplied [GH-1505]
* `azurerm_key_vault_key` - handling the parent Key Vault being deleted ([#1535](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1535))
* `azurerm_sql_database` - fix `requested_service_objective_name` updates ([#1503](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1503))
* `azurerm_storage_account` - limiting the `tags` field to 128 characters to match the service ([#1524](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1524))
* `azurerm_virtual_network_gateway` - fix `azurerm_virtual_network_gateway` crashing when `vpn_client_configuration` was not supplied ([#1505](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1505))

## 1.8.0 (June 28, 2018)

Expand Down
8 changes: 8 additions & 0 deletions azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ type ArmClient struct {
// Authentication
roleAssignmentsClient authorization.RoleAssignmentsClient
roleDefinitionsClient authorization.RoleDefinitionsClient
applicationsClient graphrbac.ApplicationsClient
servicePrincipalsClient graphrbac.ServicePrincipalsClient

// CDN
Expand Down Expand Up @@ -486,6 +487,13 @@ func (c *ArmClient) registerAuthentication(endpoint, graphEndpoint, subscription
definitionsClient.SkipResourceProviderRegistration = c.skipProviderRegistration
c.roleDefinitionsClient = definitionsClient

applicationsClient := graphrbac.NewApplicationsClientWithBaseURI(graphEndpoint, tenantId)
setUserAgent(&applicationsClient.Client)
applicationsClient.Authorizer = graphAuth
applicationsClient.Sender = sender
applicationsClient.SkipResourceProviderRegistration = c.skipProviderRegistration
c.applicationsClient = applicationsClient

servicePrincipalsClient := graphrbac.NewServicePrincipalsClientWithBaseURI(graphEndpoint, tenantId)
setUserAgent(&servicePrincipalsClient.Client)
servicePrincipalsClient.Authorizer = graphAuth
Expand Down
160 changes: 160 additions & 0 deletions azurerm/data_source_azuread_application.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
package azurerm

import (
"fmt"

"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

func dataSourceArmAzureADApplication() *schema.Resource {
return &schema.Resource{
Read: dataSourceArmAzureADApplicationRead,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
// TODO: customizeDiff for validation of either name or object_id.

Schema: map[string]*schema.Schema{
"object_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ConflictsWith: []string{"name"},
},

"name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ConflictsWith: []string{"object_id"},
},

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

"identifier_uris": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},

"reply_urls": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},

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

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

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

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

var application graphrbac.Application

if oId, ok := d.GetOk("object_id"); ok {
objectId := oId.(string)
resp, err := client.Get(ctx, objectId)
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
return fmt.Errorf("Error: AzureAD Application with ID %q was not found", objectId)
}

return fmt.Errorf("Error making Read request on AzureAD Application with ID %q: %+v", objectId, err)
}

application = resp
} else {
resp, err := client.ListComplete(ctx, "")
if err != nil {
return fmt.Errorf("Error listing Azure AD Applications: %+v", err)
}

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

var app *graphrbac.Application
for _, v := range *resp.Response().Value {
if v.DisplayName != nil {
if *v.DisplayName == name {
app = &v
break
}
}
}

if app == nil {
return fmt.Errorf("Couldn't locate an Azure AD Application with a name of %q", name)
}

application = *app
}

d.SetId(*application.ObjectID)

d.Set("object_id", application.ObjectID)
d.Set("name", application.DisplayName)
d.Set("application_id", application.AppID)
d.Set("homepage", application.Homepage)
d.Set("available_to_other_tenants", application.AvailableToOtherTenants)
d.Set("oauth2_allow_implicit_flow", application.Oauth2AllowImplicitFlow)

identifierUris := flattenAzureADDataSourceApplicationIdentifierUris(application.IdentifierUris)
if err := d.Set("identifier_uris", identifierUris); err != nil {
return fmt.Errorf("Error setting `identifier_uris`: %+v", err)
}

replyUrls := flattenAzureADDataSourceApplicationReplyUrls(application.ReplyUrls)
if err := d.Set("reply_urls", replyUrls); err != nil {
return fmt.Errorf("Error setting `reply_urls`: %+v", err)
}

return nil
}

func flattenAzureADDataSourceApplicationIdentifierUris(input *[]string) []string {
output := make([]string, 0)

if input != nil {
for _, v := range *input {
output = append(output, v)
}
}

return output
}

func flattenAzureADDataSourceApplicationReplyUrls(input *[]string) []string {
output := make([]string, 0)

if input != nil {
for _, v := range *input {
output = append(output, v)
}
}

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

import (
"fmt"
"testing"

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

func TestAccDataSourceAzureRMAzureADApplication_byObjectId(t *testing.T) {
dataSourceName := "data.azurerm_azuread_application.test"
id := uuid.New().String()
config := testAccDataSourceAzureRMAzureADApplication_objectId(id)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMActiveDirectoryApplicationDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMActiveDirectoryApplicationExists(dataSourceName),
resource.TestCheckResourceAttr(dataSourceName, "name", fmt.Sprintf("acctest%s", id)),
resource.TestCheckResourceAttr(dataSourceName, "homepage", fmt.Sprintf("http://acctest%s", id)),
resource.TestCheckResourceAttr(dataSourceName, "identifier_uris.#", "0"),
resource.TestCheckResourceAttr(dataSourceName, "reply_urls.#", "0"),
resource.TestCheckResourceAttr(dataSourceName, "oauth2_allow_implicit_flow", "false"),
resource.TestCheckResourceAttrSet(dataSourceName, "application_id"),
),
},
},
})
}

func TestAccDataSourceAzureRMAzureADApplication_byObjectIdComplete(t *testing.T) {
dataSourceName := "data.azurerm_azuread_application.test"
id := uuid.New().String()
config := testAccDataSourceAzureRMAzureADApplication_objectIdComplete(id)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMActiveDirectoryApplicationDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMActiveDirectoryApplicationExists(dataSourceName),
resource.TestCheckResourceAttr(dataSourceName, "name", fmt.Sprintf("acctest%s", id)),
resource.TestCheckResourceAttr(dataSourceName, "homepage", fmt.Sprintf("http://homepage-%s", id)),
resource.TestCheckResourceAttr(dataSourceName, "identifier_uris.#", "1"),
resource.TestCheckResourceAttr(dataSourceName, "reply_urls.#", "1"),
resource.TestCheckResourceAttr(dataSourceName, "oauth2_allow_implicit_flow", "true"),
resource.TestCheckResourceAttrSet(dataSourceName, "application_id"),
),
},
},
})
}

func TestAccDataSourceAzureRMAzureADApplication_byName(t *testing.T) {
dataSourceName := "data.azurerm_azuread_application.test"
id := uuid.New().String()
config := testAccDataSourceAzureRMAzureADApplication_name(id)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMActiveDirectoryApplicationDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMActiveDirectoryApplication_basic(id),
},
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMActiveDirectoryApplicationExists(dataSourceName),
resource.TestCheckResourceAttr(dataSourceName, "name", fmt.Sprintf("acctest%s", id)),
resource.TestCheckResourceAttr(dataSourceName, "homepage", fmt.Sprintf("http://acctest%s", id)),
resource.TestCheckResourceAttr(dataSourceName, "identifier_uris.#", "0"),
resource.TestCheckResourceAttr(dataSourceName, "reply_urls.#", "0"),
resource.TestCheckResourceAttr(dataSourceName, "oauth2_allow_implicit_flow", "false"),
resource.TestCheckResourceAttrSet(dataSourceName, "application_id"),
),
},
},
})
}

func testAccDataSourceAzureRMAzureADApplication_objectId(id string) string {
template := testAccAzureRMActiveDirectoryApplication_basic(id)
return fmt.Sprintf(`
%s
data "azurerm_azuread_application" "test" {
object_id = "${azurerm_azuread_application.test.id}"
}
`, template)
}

func testAccDataSourceAzureRMAzureADApplication_objectIdComplete(id string) string {
template := testAccAzureRMActiveDirectoryApplication_complete(id)
return fmt.Sprintf(`
%s
data "azurerm_azuread_application" "test" {
object_id = "${azurerm_azuread_application.test.id}"
}
`, template)
}

func testAccDataSourceAzureRMAzureADApplication_name(id string) string {
template := testAccAzureRMActiveDirectoryApplication_basic(id)
return fmt.Sprintf(`
%s
data "azurerm_azuread_application" "test" {
name = "${azurerm_azuread_application.test.name}"
}
`, template)
}
Loading

0 comments on commit 2004c75

Please sign in to comment.