Skip to content
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

merge upstream into my fork #2

Merged
merged 75 commits into from
Dec 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
f615474
Provision sample for ASP.NET on azure_rm_app_service
pjmolina Oct 9, 2017
7fcea4d
Added vnet datasource
Oct 30, 2017
d3072dd
add identity property to vm
hbuckle Nov 1, 2017
e363abd
refactor, tests and docs
hbuckle Nov 1, 2017
154f077
added vnet_peering
Nov 1, 2017
054102a
changing to TypeMap
Nov 2, 2017
5c16837
Updating the Provider block
tombuildsstuff Nov 4, 2017
65805ab
Variable consistency and removing unused variables
tombuildsstuff Nov 4, 2017
c32a560
Changed to azure_virtual_network, added crash control and added docum…
Nov 15, 2017
8a6346c
vmss: Support for updating the customData field
tombuildsstuff Nov 14, 2017
a00bce9
Merge pull request #559 from terraform-providers/vmss-custom-data
tombuildsstuff Nov 16, 2017
5907ba4
Updating to include #559
tombuildsstuff Nov 16, 2017
8ae6169
Support for Auto Inflating
tombuildsstuff Nov 16, 2017
c8141c7
New Resource: `azurerm_network_watcher`
tombuildsstuff Nov 17, 2017
7cd9522
Merge pull request #569 from terraform-providers/eventhub-namespace-u…
tombuildsstuff Nov 17, 2017
2c3e9a2
Updating to include #569
tombuildsstuff Nov 17, 2017
b8b4aa7
Hotfix: upgrade packages under go-autorest to be v9.4.1.
metacpp Nov 17, 2017
5b802d4
Vendoring the Locks SDK
tombuildsstuff Nov 18, 2017
facd2a5
New Resource: `azurerm_management_lock`
tombuildsstuff Nov 18, 2017
d5b0c67
Merge pull request #573 from metacpp/master
tombuildsstuff Nov 20, 2017
7af9693
Updating to include #573
tombuildsstuff Nov 20, 2017
b247913
Merge pull request #571 from terraform-providers/network-watcher
tombuildsstuff Nov 21, 2017
f3f6c4c
Updating to include #571
tombuildsstuff Nov 21, 2017
0f63744
Merge branch 'master' into locks
tombuildsstuff Nov 21, 2017
8fe5b5f
Adding validation for the locks name
tombuildsstuff Nov 21, 2017
032c7ac
Linting
tombuildsstuff Nov 21, 2017
767f286
Merge pull request #575 from terraform-providers/locks
tombuildsstuff Nov 21, 2017
487c48f
Updating to include #575
tombuildsstuff Nov 21, 2017
f9f121e
Updating the changelog for consistency
tombuildsstuff Nov 21, 2017
b5be3fa
removed tabs, used spaces
Nov 26, 2017
4b94d48
add test for issue #450
sebastus Nov 28, 2017
ac14281
Updated the way user agent string gets assigned.
Nov 29, 2017
1436023
Changed code to make it more readable.
Nov 29, 2017
6e8f6ea
pr tweaks
hbuckle Nov 29, 2017
de19f2f
Avoid out of index errors when flattening image data disks.
a-palchikov Nov 29, 2017
2f817ea
Merge pull request #585 from sebastus/sebastus-routeTableTest
tombuildsstuff Nov 30, 2017
07ae076
Merge pull request #587 from jeffreyCline/master
tombuildsstuff Nov 30, 2017
dd91170
Updating to include #587
tombuildsstuff Nov 30, 2017
94cd8bf
Merge pull request #589 from gravitational/image-flatten-panic
tombuildsstuff Nov 30, 2017
61b1671
Updating to include #589
tombuildsstuff Nov 30, 2017
cd6457b
Conditional loading of the Subscription ID / Tenant ID / Environment
tombuildsstuff Nov 18, 2017
fe1e0f5
Refactoring the provider block to support determining the TenantID/En…
tombuildsstuff Nov 30, 2017
f5a01b1
Fixing the build
tombuildsstuff Nov 30, 2017
eb25459
Remove the field marked as "Removed" according to #572.
Dec 1, 2017
bd6654c
Upgrading to v11.2.2-beta of the Azure SDK for Go
tombuildsstuff Dec 1, 2017
2289eef
Merge pull request #593 from terraform-providers/remove_vm_diag_profile
tombuildsstuff Dec 1, 2017
c664ac6
Updating to include #593
tombuildsstuff Dec 1, 2017
4d94018
Fixing the Management Lock validation
tombuildsstuff Dec 4, 2017
ea22063
Adding a default value for the identity field
tombuildsstuff Dec 4, 2017
a9a362d
Merge pull request #482 from hbuckle/managed_service_identity
tombuildsstuff Dec 4, 2017
868ed36
Updating to include #482
tombuildsstuff Dec 4, 2017
9a416b5
Merge pull request #599 from terraform-providers/fixing-management-lo…
tombuildsstuff Dec 4, 2017
1005762
Merge pull request #574 from terraform-providers/provider-block
tombuildsstuff Dec 6, 2017
ad6d27e
Updating to include #574
tombuildsstuff Dec 6, 2017
3cc2133
Adding settings to the hash
tombuildsstuff Dec 6, 2017
df8a94a
Merge pull request #609 from terraform-providers/vmss-extension
tombuildsstuff Dec 6, 2017
0bfceba
Updating to include #609
tombuildsstuff Dec 6, 2017
257361e
Local Network Gateways: support for BGP Settings
tombuildsstuff Dec 7, 2017
b58f95b
Refactoring
tombuildsstuff Dec 7, 2017
a36e197
Adding an import test for BGP Settings:
tombuildsstuff Dec 7, 2017
d340a00
Splitting the data source out into it's own step
tombuildsstuff Dec 8, 2017
e9a3ea6
Minor refactoring
tombuildsstuff Dec 8, 2017
57c8034
Merge pull request #533 from dcaro/vnet_data_source
tombuildsstuff Dec 8, 2017
bc6c649
Updating to include #533
tombuildsstuff Dec 8, 2017
1c12384
Exporting the Default Hostname field
tombuildsstuff Dec 8, 2017
10633c6
Updating the App Service example to be complete
tombuildsstuff Dec 8, 2017
5d0e963
Merge pull request #594 from terraform-providers/sdk-11-2-2
tombuildsstuff Dec 8, 2017
88101f6
Updating to include #594
tombuildsstuff Dec 8, 2017
4128010
Merge pull request #611 from terraform-providers/local-network-gatewa…
tombuildsstuff Dec 8, 2017
40e0f0a
Updating to include #611
tombuildsstuff Dec 8, 2017
bac602a
Merge pull request #612 from terraform-providers/app-service-site-name
tombuildsstuff Dec 8, 2017
f717de2
Updating to include #612
tombuildsstuff Dec 8, 2017
a3b207f
Merge pull request #407 from metadevpro/app-service-asp-net-sample
tombuildsstuff Dec 8, 2017
897428e
Remove leading line break from key_vault_key docs
trotttrotttrott Dec 8, 2017
3e1c6f2
Merge pull request #613 from trotttrotttrott/doc-metadata-ignored
tombuildsstuff Dec 8, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
## 1.0.0 (Unreleased)

FEATURES:

* **New Data Source:** `azurerm_virtual_network` [GH-533]
* **New Resource:** `azurerm_management_lock` [GH-575]
* **New Resource:** `azurerm_network_watcher` [GH-571]

IMPROVEMENTS:

* `azurerm_eventhub_namespace`: capacity can now be configured up to 20 [GH-556]
* authentication - add support for the latest Azure CLI configuration [GH-573]
* authentication - conditional loading of the Subscription ID / Tenant ID / Environment [GH-574]
* core - appending additions to the User Agent, so we don't overwrite the Go SDK User Agent info [GH-587]
* core: Upgrading to v11.2.2-beta of the Azure SDK for Go [GH-594]
* `azurerm_app_service` - exposing the Default Hostname as a Computed field [GH-612]
* `azurerm_eventhub_namespace` - capacity can now be configured up to 20 [GH-556]
* `azurerm_eventhub_namespace` - support for AutoInflating/MaximumThroughputCapacity [GH-569]
* `azurerm_image` - fixing an out of index error when flattening image data disks [GH-589]
* `azurerm_local_network_gateway` - support for BGP Settings [GH-611]
* `azurerm_virtual_machine` - removing the deprecated `diagnostics_profile` field [GH-593]
* `azurerm_virtual_machine` - support for managed service identity [GH-482]
* `azurerm_virtual_machine_scale_set` - Support for updating the customData field [GH-559]
* `azurerm_virtual_machine_scale_set` - ensuring changes to the `settings` object are detected [GH-609]

## 0.3.3 (November 14, 2017)

Expand Down
5 changes: 3 additions & 2 deletions azurerm/azurerm_sweeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/authentication"
)

func TestMain(m *testing.M) {
Expand All @@ -29,7 +30,7 @@ func buildConfigForSweepers() (*ArmClient, error) {
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{
config := &authentication.Config{
SubscriptionID: subscriptionID,
ClientID: clientID,
ClientSecret: clientSecret,
Expand All @@ -38,7 +39,7 @@ func buildConfigForSweepers() (*ArmClient, error) {
SkipProviderRegistration: false,
}

return config.getArmClient()
return getArmClient(config)
}

func shouldSweepAcceptanceTestResource(name string, resourceLocation string, region string) bool {
Expand Down
49 changes: 41 additions & 8 deletions azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/Azure/azure-sdk-for-go/arm/operationalinsights"
"github.com/Azure/azure-sdk-for-go/arm/postgresql"
"github.com/Azure/azure-sdk-for-go/arm/redis"
"github.com/Azure/azure-sdk-for-go/arm/resources/locks"
"github.com/Azure/azure-sdk-for-go/arm/resources/resources"
"github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions"
"github.com/Azure/azure-sdk-for-go/arm/scheduler"
Expand All @@ -43,6 +44,7 @@ import (
"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/hashicorp/terraform/terraform"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/authentication"
)

// ArmClient contains the handles to all the specific Azure Resource Manager
Expand Down Expand Up @@ -160,6 +162,12 @@ type ArmClient struct {
sqlElasticPoolsClient sql.ElasticPoolsClient
sqlFirewallRulesClient sql.FirewallRulesClient
sqlServersClient sql.ServersClient

// Networking
watcherClient network.WatchersClient

// Resources
managementLocksClient locks.ManagementLocksClient
}

func withRequestLogging() autorest.SendDecorator {
Expand Down Expand Up @@ -191,16 +199,22 @@ func withRequestLogging() autorest.SendDecorator {
}

func setUserAgent(client *autorest.Client) {
version := terraform.VersionString()
client.UserAgent = fmt.Sprintf("HashiCorp-Terraform-v%s", version)
tfVersion := fmt.Sprintf("HashiCorp-Terraform-v%s", terraform.VersionString())

// if the user agent already has a value append the Terraform user agent string
if curUserAgent := client.UserAgent; curUserAgent != "" {
client.UserAgent = fmt.Sprintf("%s;%s", curUserAgent, tfVersion)
} else {
client.UserAgent = tfVersion
}

// append the CloudShell version to the user agent
// append the CloudShell version to the user agent if it exists
if azureAgent := os.Getenv("AZURE_HTTP_USER_AGENT"); azureAgent != "" {
client.UserAgent = fmt.Sprintf("%s;%s", client.UserAgent, azureAgent)
}
}

func (c *Config) getAuthorizationToken(oauthConfig *adal.OAuthConfig, endpoint string) (*autorest.BearerAuthorizer, error) {
func getAuthorizationToken(c *authentication.Config, oauthConfig *adal.OAuthConfig, endpoint string) (*autorest.BearerAuthorizer, error) {
useServicePrincipal := c.ClientSecret != ""

if useServicePrincipal {
Expand Down Expand Up @@ -232,7 +246,7 @@ func (c *Config) getAuthorizationToken(oauthConfig *adal.OAuthConfig, endpoint s

// getArmClient is a helper method which returns a fully instantiated
// *ArmClient based on the Config's current settings.
func (c *Config) getArmClient() (*ArmClient, error) {
func getArmClient(c *authentication.Config) (*ArmClient, error) {
// detect cloud from environment
env, envErr := azure.EnvironmentFromName(c.Environment)
if envErr != nil {
Expand Down Expand Up @@ -267,21 +281,21 @@ func (c *Config) getArmClient() (*ArmClient, error) {

// Resource Manager endpoints
endpoint := env.ResourceManagerEndpoint
auth, err := c.getAuthorizationToken(oauthConfig, endpoint)
auth, err := getAuthorizationToken(c, oauthConfig, endpoint)
if err != nil {
return nil, err
}

// Graph Endpoints
graphEndpoint := env.GraphEndpoint
graphAuth, err := c.getAuthorizationToken(oauthConfig, graphEndpoint)
graphAuth, err := getAuthorizationToken(c, oauthConfig, graphEndpoint)
if err != nil {
return nil, err
}

// Key Vault Endpoints
keyVaultAuth := autorest.NewBearerAuthorizerCallback(sender, func(tenantID, resource string) (*autorest.BearerAuthorizer, error) {
keyVaultSpt, err := c.getAuthorizationToken(oauthConfig, resource)
keyVaultSpt, err := getAuthorizationToken(c, oauthConfig, resource)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -655,11 +669,22 @@ func (c *Config) getArmClient() (*ArmClient, error) {
client.registerDatabases(endpoint, c.SubscriptionID, auth, sender)
client.registerDisks(endpoint, c.SubscriptionID, auth, sender)
client.registerKeyVaultClients(endpoint, c.SubscriptionID, auth, keyVaultAuth, sender)
client.registerNetworkingClients(endpoint, c.SubscriptionID, auth, sender)
client.registerRedisClients(endpoint, c.SubscriptionID, auth, sender)
client.registerResourcesClients(endpoint, c.SubscriptionID, auth, sender)

return &client, nil
}

func (c *ArmClient) registerNetworkingClients(endpoint, subscriptionId string, auth autorest.Authorizer, sender autorest.Sender) {
// TODO: move the other networking stuff in here, gradually
watchersClient := network.NewWatchersClientWithBaseURI(endpoint, subscriptionId)
setUserAgent(&watchersClient.Client)
watchersClient.Authorizer = auth
watchersClient.Sender = sender
c.watcherClient = watchersClient
}

func (c *ArmClient) registerAuthentication(endpoint, graphEndpoint, subscriptionId, tenantId string, auth, graphAuth autorest.Authorizer, sender autorest.Sender) {
spc := graphrbac.NewServicePrincipalsClientWithBaseURI(graphEndpoint, tenantId)
setUserAgent(&spc.Client)
Expand Down Expand Up @@ -805,6 +830,14 @@ func (c *ArmClient) registerRedisClients(endpoint, subscriptionId string, auth a
c.redisPatchSchedulesClient = patchSchedulesClient
}

func (c *ArmClient) registerResourcesClients(endpoint, subscriptionId string, auth autorest.Authorizer, sender autorest.Sender) {
locksClient := locks.NewManagementLocksClientWithBaseURI(endpoint, subscriptionId)
setUserAgent(&locksClient.Client)
locksClient.Authorizer = auth
locksClient.Sender = sender
c.managementLocksClient = locksClient
}

func (armClient *ArmClient) getKeyForStorageAccount(resourceGroupName, storageAccountName string) (string, bool, error) {
accountKeys, err := armClient.storageServiceClient.ListKeys(resourceGroupName, storageAccountName)
if accountKeys.StatusCode == http.StatusNotFound {
Expand Down
132 changes: 132 additions & 0 deletions azurerm/data_source_virtual_network.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package azurerm

import (
"fmt"

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

func dataSourceArmVirtualNetwork() *schema.Resource {
return &schema.Resource{
Read: dataSourceArmVnetRead,
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},

"resource_group_name": {
Type: schema.TypeString,
Required: true,
},

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

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

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

"vnet_peerings": {
Type: schema.TypeMap,
Computed: true,
},
},
}
}

func dataSourceArmVnetRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).vnetClient

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

resp, err := client.Get(resGroup, name, "")
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
return fmt.Errorf("Error making Read request on Azure virtual network %q (resource group %q): %+v", name, resGroup, err)
}
return err
}

d.SetId(*resp.ID)

if props := resp.VirtualNetworkPropertiesFormat; props != nil {
addressSpaces := flattenVnetAddressPrefixes(props.AddressSpace.AddressPrefixes)
if err := d.Set("address_spaces", addressSpaces); err != nil {
return err
}

dnsServers := flattenVnetAddressPrefixes(props.DhcpOptions.DNSServers)
if err := d.Set("dns_servers", dnsServers); err != nil {
return err
}

subnets := flattenVnetSubnetsNames(props.Subnets)
if err := d.Set("subnets", subnets); err != nil {
return err
}

vnetPeerings := flattenVnetPeerings(props.VirtualNetworkPeerings)
if err := d.Set("vnet_peerings", vnetPeerings); err != nil {
return err
}
}
return nil
}

func flattenVnetAddressPrefixes(input *[]string) []interface{} {
prefixes := make([]interface{}, 0)

if myprefixes := input; myprefixes != nil {
for _, prefix := range *myprefixes {
prefixes = append(prefixes, prefix)
}
}
return prefixes
}

func flattenVnetSubnetsNames(input *[]network.Subnet) []interface{} {
subnets := make([]interface{}, 0)

if mysubnets := input; mysubnets != nil {
for _, subnet := range *mysubnets {
subnets = append(subnets, *subnet.Name)
}
}
return subnets
}

func flattenVnetPeerings(input *[]network.VirtualNetworkPeering) map[string]interface{} {
output := make(map[string]interface{}, 0)

if peerings := input; peerings != nil {
for _, vnetpeering := range *peerings {
key := *vnetpeering.Name
value := *vnetpeering.RemoteVirtualNetwork.ID

output[key] = value

}
}
return output
}
Loading