Skip to content

Commit

Permalink
Merge branch 'master' into feature/virtual-network-gateway
Browse files Browse the repository at this point in the history
# Conflicts:
#	azurerm/provider.go
#	website/azurerm.erb
  • Loading branch information
dominik-lekse committed Aug 5, 2017
2 parents b89586f + 99cf687 commit 2990404
Show file tree
Hide file tree
Showing 327 changed files with 20,782 additions and 3,042 deletions.
71 changes: 57 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,85 @@
## 0.1.2 (Unreleased)
## 0.1.5 (Unreleased)

IMPROVEMENTS:

* `azurerm_sql_*` - upgrading to version `2014-04-01` of the SQL API's [GH-201]
* `azurerm_virtual_machine_scale_set` - support for custom images and managed disks [GH-203]

BUG FIXES:

* `azurerm_sql_database` - fixing creating a DB with a PointInTimeRestore [GH-197]
* `azurerm_virtual_machine` - fix a crash when the properties for a network inteface aren't returned [GH-208]
* Checking to ensure the HTTP Response isn't `nil` before accessing it (fixes [GH-200]) [GH-204]

## 0.1.4 (July 26, 2017)

BUG FIXES:

* `azurerm_dns_*` - upgrading to version `2016-04-01` of the Azure DNS API by switching from Riviera -> Azure SDK for Go ([#192](https://github.com/terraform-providers/terraform-provider-azurerm/issues/192))

## 0.1.3 (July 21, 2017)

FEATURES:

* **New Resource:** `azurerm_dns_ptr_record` ([#141](https://github.com/terraform-providers/terraform-provider-azurerm/issues/141))
* **New Resource:**`azurerm_image` ([#8](https://github.com/terraform-providers/terraform-provider-azurerm/issues/8))
* **New Resource:** `azurerm_servicebus_queue` ([#151](https://github.com/terraform-providers/terraform-provider-azurerm/issues/151))

IMPROVEMENTS:

* `azurerm_client_config` - added a `service_principal_object_id` attribute to the data source ([#175](https://github.com/terraform-providers/terraform-provider-azurerm/issues/175))
* `azurerm_search_service` - added import support ([#172](https://github.com/terraform-providers/terraform-provider-azurerm/issues/172))
* `azurerm_servicebus_topic` - added a `status` field to allow disabling the topic ([#150](https://github.com/terraform-providers/terraform-provider-azurerm/issues/150))
* `azurerm_storage_account` - Added support for Require secure transfer ([#167](https://github.com/terraform-providers/terraform-provider-azurerm/issues/167))
* `azurerm_storage_table` - updating the name validation ([#143](https://github.com/terraform-providers/terraform-provider-azurerm/issues/143))
* `azurerm_virtual_machine` - making `admin_password` optional for Linux VM's ([#154](https://github.com/terraform-providers/terraform-provider-azurerm/issues/154))
* `azurerm_virtual_machine_scale_set` - adding a `plan` block for Marketplace images ([#161](https://github.com/terraform-providers/terraform-provider-azurerm/issues/161))

## 0.1.2 (June 29, 2017)

FEATURES:

* **New Data Source:** `azurerm_managed_disk` [GH-121]
* **New Resource:** `azurerm_application_insights` [GH-3]
* `azurerm_network_interface` now supports import [GH-119]
* **New Data Source:** `azurerm_managed_disk` ([#121](https://github.com/terraform-providers/terraform-provider-azurerm/issues/121))
* **New Resource:** `azurerm_application_insights` ([#3](https://github.com/terraform-providers/terraform-provider-azurerm/issues/3))
* **New Resource:** `azurerm_cosmosdb_account` ([#108](https://github.com/terraform-providers/terraform-provider-azurerm/issues/108))
* `azurerm_network_interface` now supports import ([#119](https://github.com/terraform-providers/terraform-provider-azurerm/issues/119))

IMPROVEMENTS:

* Ensuring consistency in when storing the `location` field in the state for the `azurerm_availability_set`, `azurerm_express_route_circuit`, `azurerm_load_balancer`, `azurerm_local_network_gateway`, `azurerm_managed_disk`, `azurerm_network_security_group`
`azurerm_public_ip`, `azurerm_resource_group`, `azurerm_route_table`, `azurerm_storage_account`, `azurerm_virtual_machine` and `azurerm_virtual_network` resources [GH-123]
`azurerm_public_ip`, `azurerm_resource_group`, `azurerm_route_table`, `azurerm_storage_account`, `azurerm_virtual_machine` and `azurerm_virtual_network` resources ([#123](https://github.com/terraform-providers/terraform-provider-azurerm/issues/123))
* `azurerm_redis_cache` - now supports backup settings for Premium Redis Cache's ([#130](https://github.com/terraform-providers/terraform-provider-azurerm/issues/130))
* `azurerm_storage_account` - exposing a formatted Connection String for Blob access ([#142](https://github.com/terraform-providers/terraform-provider-azurerm/issues/142))

BUG FIXES:

* `azurerm_container_service` - exposes the FQDN of the master_profile as a computed field [GH-125]
* `azurerm_key_vault` - fixing import / the validation on Access Policies [GH-124]
* `azurerm_network_interface` - Normalizing the location field in the state [GH-122]
* `azurerm_network_interface` - fixing a crash when importing a NIC with a Public IP [GH-128]
* `azurerm_subnet` now correctly detects changes to Network Securtiy Groups and Routing Table's [GH-113]
* `azurerm_cdn_endpoint` - fixing update of the `origin_host_header` ([#134](https://github.com/terraform-providers/terraform-provider-azurerm/issues/134))
* `azurerm_container_service` - exposes the FQDN of the `master_profile` as a computed field ([#125](https://github.com/terraform-providers/terraform-provider-azurerm/issues/125))
* `azurerm_key_vault` - fixing import / the validation on Access Policies ([#124](https://github.com/terraform-providers/terraform-provider-azurerm/issues/124))
* `azurerm_network_interface` - Normalizing the location field in the state ([#122](https://github.com/terraform-providers/terraform-provider-azurerm/issues/122))
* `azurerm_network_interface` - fixing a crash when importing a NIC with a Public IP ([#128](https://github.com/terraform-providers/terraform-provider-azurerm/issues/128))
* `azurerm_network_security_rule`: `network_security_group_name` is now `ForceNew` ([#138](https://github.com/terraform-providers/terraform-provider-azurerm/issues/138))
* `azurerm_subnet` now correctly detects changes to Network Securtiy Groups and Routing Table's ([#113](https://github.com/terraform-providers/terraform-provider-azurerm/issues/113))
* `azurerm_virtual_machine_scale_set` - making `storage_profile_os_disk`.`name` optional ([#129](https://github.com/terraform-providers/terraform-provider-azurerm/issues/129))

## 0.1.1 (June 21, 2017)

BUG FIXES:

* Sort ResourceID.Path keys for consistent output ([#116](https://github.com/terraform-providers/terraform-provider-azurerm/116))
* Sort ResourceID.Path keys for consistent output ([#116](https://github.com/terraform-providers/terraform-provider-azurerm/issues/116))

## 0.1.0 (June 20, 2017)

BACKWARDS INCOMPATIBILITIES / NOTES:

FEATURES:

* **New Data Source:** `azurerm_resource_group` [[#15022](https://github.com/terraform-providers/terraform-provider-azurerm/15022)](https://github.com/hashicorp/terraform/pull/15022)
* **New Data Source:** `azurerm_resource_group` [[#15022](https://github.com/terraform-providers/terraform-provider-azurerm/issues/15022)](https://github.com/hashicorp/terraform/pull/15022)

IMPROVEMENTS:

* Add diff supress func to endpoint_location [[#15094](https://github.com/terraform-providers/terraform-provider-azurerm/15094)](https://github.com/hashicorp/terraform/pull/15094)
* Add diff supress func to endpoint_location [[#15094](https://github.com/terraform-providers/terraform-provider-azurerm/issues/15094)](https://github.com/hashicorp/terraform/pull/15094)

BUG FIXES:

* Fixing the Deadlock issue ([#6](https://github.com/terraform-providers/terraform-provider-azurerm/6))
* Fixing the Deadlock issue ([#6](https://github.com/terraform-providers/terraform-provider-azurerm/issues/6))
19 changes: 4 additions & 15 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
TEST?=$$(go list ./... |grep -v 'vendor')
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
COVER_TEST?=$$(go list ./... |grep -v 'vendor')

default: build

Expand All @@ -15,17 +14,6 @@ test: fmtcheck
testacc: fmtcheck
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m

testrace: fmtcheck
TF_ACC= go test -race $(TEST) $(TESTARGS)

cover:
@go tool cover 2>/dev/null; if [ $$? -eq 3 ]; then \
go get -u golang.org/x/tools/cmd/cover; \
fi
go test $(COVER_TEST) -coverprofile=coverage.out
go tool cover -html=coverage.out
rm coverage.out

vet:
@echo "go vet ."
@go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \
Expand All @@ -47,12 +35,13 @@ errcheck:
vendor-status:
@govendor status

test-compile: fmtcheck
test-compile:
@if [ "$(TEST)" = "./..." ]; then \
echo "ERROR: Set TEST to a specific package. For example,"; \
echo " make test-compile TEST=./builtin/providers/aws"; \
echo " make test-compile TEST=./aws"; \
exit 1; \
fi
go test -c $(TEST) $(TESTARGS)

.PHONY: build test testacc testrace cover vet fmt fmtcheck errcheck vendor-status test-compile
.PHONY: build test testacc vet fmt fmtcheck errcheck vendor-status test-compile

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Terraform Provider
- [![Gitter chat](https://badges.gitter.im/hashicorp-terraform/Lobby.png)](https://gitter.im/hashicorp-terraform/Lobby)
- Mailing list: [Google Groups](http://groups.google.com/group/terraform-tool)

![Terraform](https://rawgithub.com/hashicorp/terraform/master/website/source/assets/images/logo-hashicorp.svg)
<img src="https://cdn.rawgit.com/hashicorp/terraform-website/master/source/assets/images/logo-text.svg" width="600px">

Requirements
------------
Expand Down
65 changes: 65 additions & 0 deletions azurerm/azurerm_sweeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package azurerm

import (
"fmt"
"log"
"os"
"strings"
"testing"

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

func TestMain(m *testing.M) {
resource.TestMain(m)
}

func buildConfigForSweepers() (*ArmClient, error) {
subscriptionID := os.Getenv("ARM_SUBSCRIPTION_ID")
clientID := os.Getenv("ARM_CLIENT_ID")
clientSecret := os.Getenv("ARM_CLIENT_SECRET")
tenantID := os.Getenv("ARM_TENANT_ID")
environment := os.Getenv("ARM_ENVIRONMENT")

if environment == "" {
environment = "public"
}

if subscriptionID == "" || clientID == "" || clientSecret == "" || tenantID == "" {
return nil, fmt.Errorf("ARM_SUBSCRIPTION_ID, ARM_CLIENT_ID, ARM_CLIENT_SECRET and ARM_TENANT_ID must be set for acceptance tests")
}

config := &Config{
SubscriptionID: subscriptionID,
ClientID: clientID,
ClientSecret: clientSecret,
TenantID: tenantID,
Environment: environment,
SkipProviderRegistration: false,
}

return config.getArmClient()
}

func shouldSweepAcceptanceTestResource(name string, resourceLocation string, region string) bool {
loweredName := strings.ToLower(name)

prefixesToIgnore := []string{"acctest"}

for _, prefix := range prefixesToIgnore {
if !strings.HasPrefix(loweredName, prefix) {
log.Printf("Ignoring Resource '%s' due to prefix '%s'", name, prefix)
return false
}
}

normalisedResourceLocation := azureRMNormalizeLocation(resourceLocation)
normalisedRegion := azureRMNormalizeLocation(region)

if normalisedResourceLocation != normalisedRegion {
log.Printf("Region '%s' isn't '%s' - skipping", normalisedResourceLocation, normalisedRegion)
return false
}

return true
}
55 changes: 54 additions & 1 deletion azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ import (
"github.com/Azure/azure-sdk-for-go/arm/compute"
"github.com/Azure/azure-sdk-for-go/arm/containerregistry"
"github.com/Azure/azure-sdk-for-go/arm/containerservice"
"github.com/Azure/azure-sdk-for-go/arm/cosmos-db"
"github.com/Azure/azure-sdk-for-go/arm/disk"
"github.com/Azure/azure-sdk-for-go/arm/dns"
"github.com/Azure/azure-sdk-for-go/arm/eventhub"
"github.com/Azure/azure-sdk-for-go/arm/graphrbac"
"github.com/Azure/azure-sdk-for-go/arm/keyvault"
"github.com/Azure/azure-sdk-for-go/arm/network"
"github.com/Azure/azure-sdk-for-go/arm/redis"
Expand Down Expand Up @@ -50,8 +53,10 @@ type ArmClient struct {
vmScaleSetClient compute.VirtualMachineScaleSetsClient
vmImageClient compute.VirtualMachineImagesClient
vmClient compute.VirtualMachinesClient
imageClient compute.ImagesClient

diskClient disk.DisksClient
diskClient disk.DisksClient
cosmosDBClient cosmosdb.DatabaseAccountsClient

appGatewayClient network.ApplicationGatewaysClient
ifaceClient network.InterfacesClient
Expand All @@ -69,6 +74,8 @@ type ArmClient struct {
vnetPeeringsClient network.VirtualNetworkPeeringsClient
routeTablesClient network.RouteTablesClient
routesClient network.RoutesClient
dnsClient dns.RecordSetsClient
zonesClient dns.ZonesClient

cdnProfilesClient cdn.ProfilesClient
cdnEndpointsClient cdn.EndpointsClient
Expand Down Expand Up @@ -99,6 +106,7 @@ type ArmClient struct {
trafficManagerEndpointsClient trafficmanager.EndpointsClient

serviceBusNamespacesClient servicebus.NamespacesClient
serviceBusQueuesClient servicebus.QueuesClient
serviceBusTopicsClient servicebus.TopicsClient
serviceBusSubscriptionsClient servicebus.SubscriptionsClient

Expand All @@ -107,6 +115,8 @@ type ArmClient struct {
sqlElasticPoolsClient sql.ElasticPoolsClient

appInsightsClient appinsights.ComponentsClient

servicePrincipalsClient graphrbac.ServicePrincipalsClient
}

func withRequestLogging() autorest.SendDecorator {
Expand Down Expand Up @@ -192,8 +202,15 @@ func (c *Config) getArmClient() (*ArmClient, error) {
return nil, err
}

graphSpt, err := adal.NewServicePrincipalToken(*oauthConfig, c.ClientID, c.ClientSecret, env.GraphEndpoint)
if err != nil {
return nil, err
}

endpoint := env.ResourceManagerEndpoint
auth := autorest.NewBearerAuthorizer(spt)
graphEndpoint := env.GraphEndpoint
graphAuth := autorest.NewBearerAuthorizer(graphSpt)

// NOTE: these declarations should be left separate for clarity should the
// clients be wished to be configured with custom Responders/PollingModess etc...
Expand Down Expand Up @@ -257,12 +274,24 @@ func (c *Config) getArmClient() (*ArmClient, error) {
csc.Sender = autorest.CreateSender(withRequestLogging())
client.containerServicesClient = csc

cdb := cosmosdb.NewDatabaseAccountsClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&cdb.Client)
cdb.Authorizer = auth
cdb.Sender = autorest.CreateSender(withRequestLogging())
client.cosmosDBClient = cdb

dkc := disk.NewDisksClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&dkc.Client)
dkc.Authorizer = auth
dkc.Sender = autorest.CreateSender(withRequestLogging())
client.diskClient = dkc

img := compute.NewImagesClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&img.Client)
img.Authorizer = auth
img.Sender = autorest.CreateSender(withRequestLogging())
client.imageClient = img

ehc := eventhub.NewEventHubsClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&ehc.Client)
ehc.Authorizer = auth
Expand Down Expand Up @@ -365,6 +394,18 @@ func (c *Config) getArmClient() (*ArmClient, error) {
rc.Sender = autorest.CreateSender(withRequestLogging())
client.routesClient = rc

dn := dns.NewRecordSetsClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&dn.Client)
dn.Authorizer = auth
dn.Sender = autorest.CreateSender(withRequestLogging())
client.dnsClient = dn

zo := dns.NewZonesClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&zo.Client)
zo.Authorizer = auth
zo.Sender = autorest.CreateSender(withRequestLogging())
client.zonesClient = zo

rgc := resources.NewGroupsClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&rgc.Client)
rgc.Authorizer = auth
Expand Down Expand Up @@ -455,6 +496,12 @@ func (c *Config) getArmClient() (*ArmClient, error) {
sbnc.Sender = autorest.CreateSender(withRequestLogging())
client.serviceBusNamespacesClient = sbnc

sbqc := servicebus.NewQueuesClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&sbqc.Client)
sbqc.Authorizer = auth
sbqc.Sender = autorest.CreateSender(withRequestLogging())
client.serviceBusQueuesClient = sbqc

sbtc := servicebus.NewTopicsClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&sbtc.Client)
sbtc.Authorizer = auth
Expand Down Expand Up @@ -485,6 +532,12 @@ func (c *Config) getArmClient() (*ArmClient, error) {
ai.Sender = autorest.CreateSender(withRequestLogging())
client.appInsightsClient = ai

spc := graphrbac.NewServicePrincipalsClientWithBaseURI(graphEndpoint, c.TenantID)
setUserAgent(&spc.Client)
spc.Authorizer = graphAuth
spc.Sender = autorest.CreateSender(withRequestLogging())
client.servicePrincipalsClient = spc

return &client, nil
}

Expand Down
22 changes: 22 additions & 0 deletions azurerm/data_source_arm_client_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package azurerm
import (
"time"

"fmt"

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

Expand All @@ -23,17 +25,37 @@ func dataSourceArmClientConfig() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"service_principal_object_id": {
Type: schema.TypeString,
Computed: true,
},
},
}
}

func dataSourceArmClientConfigRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient)
spClient := client.servicePrincipalsClient
// Application & Service Principal is 1:1 per tenant. Since we know the appId (client_id)
// here, we can query for the Service Principal whose appId matches.
filter := fmt.Sprintf("appId eq '%s'", client.clientId)
listResult, listErr := spClient.List(filter)

if listErr != nil {
return fmt.Errorf("Error listing Service Principals: %#v", listErr)
}

if listResult.Value == nil || len(*listResult.Value) != 1 {
return fmt.Errorf("Unexpected Service Principal query result: %#v", listResult.Value)
}

servicePrincipal := (*listResult.Value)[0]

d.SetId(time.Now().UTC().String())
d.Set("client_id", client.clientId)
d.Set("tenant_id", client.tenantId)
d.Set("subscription_id", client.subscriptionId)
d.Set("service_principal_object_id", *servicePrincipal.ObjectID)

return nil
}
Loading

0 comments on commit 2990404

Please sign in to comment.