opentofu/builtin/providers/azurerm/data_source_arm_client_config.go
Peter McAtominey 6374cc7d33 provider/azurerm: add client_config data source
azurerm_client_config provides access to:

 - client_id
 - tenant_id
 - subscription_id

```
TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMClientConfig -timeout 120m
=== RUN   TestAccAzureRMClientConfig_basic
--- PASS: TestAccAzureRMClientConfig_basic (27.79s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	27.862s
```
2016-10-20 11:29:48 +01:00

40 lines
778 B
Go

package azurerm
import (
"time"
"github.com/hashicorp/terraform/helper/schema"
)
func dataSourceArmClientConfig() *schema.Resource {
return &schema.Resource{
Read: dataSourceArmClientConfigRead,
Schema: map[string]*schema.Schema{
"client_id": {
Type: schema.TypeString,
Computed: true,
},
"tenant_id": {
Type: schema.TypeString,
Computed: true,
},
"subscription_id": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
func dataSourceArmClientConfigRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient)
d.SetId(time.Now().UTC().String())
d.Set("client_id", client.clientId)
d.Set("tenant_id", client.tenantId)
d.Set("subscription_id", client.subscriptionId)
return nil
}