Skip to content

Commit

Permalink
Merge pull request #2 from yaegashi/update-v0.0.3
Browse files Browse the repository at this point in the history
Update v0.0.3
  • Loading branch information
yaegashi authored Jun 30, 2020
2 parents 9b4f00b + 39f7f02 commit a683208
Show file tree
Hide file tree
Showing 9 changed files with 431 additions and 57 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WIP: Terraform Provider for Microsoft Graph
# Terraform Provider for Microsoft Graph

![Test](https://github.com/yaegashi/terraform-provider-msgraph/workflows/Test/badge.svg)
![Release](https://github.com/yaegashi/terraform-provider-msgraph/workflows/Release/badge.svg)
Expand Down Expand Up @@ -55,6 +55,10 @@ Open https://microsoft.com/devicelogin with your web browser and enter the code
After completing authorization it stores auth tokens in a file specified by `token_cache_path`.
On subsequent terraform invocations it can skip the authorization steps above with this file.

You can also specify an Azure Blob URL with SAS for `token_cache_path`.
It's recommended to pass it via `ARM_TOKEN_CACHE_PATH` envvar
since the SAS is considered sensitive information that should be hidden.

## How to test

Terraform v0.12 and Go v1.13 are required.
Expand Down Expand Up @@ -103,7 +107,7 @@ $ TF_LOG=DEBUG terraform apply
- [ ] [Site](https://docs.microsoft.com/en-us/graph/api/resources/sharepoint) (no ability to create new sites)
- [ ] Support importing
- [ ] Code auto-generation based on the API metadata
- [ ] Persist OAuth2 tokens in backend storage?
- [x] Persist OAuth2 tokens in backend storage (Azure Blob Storage)
- [ ] Better device auth grant experience (no `TF_LOG=DEBUG`)
- [ ] Unit testing
- [ ] CI/CD
Expand Down
42 changes: 38 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,44 @@
module github.com/yaegashi/terraform-provider-msgraph

go 1.13
go 1.14

require (
cloud.google.com/go v0.59.0 // indirect
cloud.google.com/go/storage v1.10.0 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/aws/aws-sdk-go v1.32.11 // indirect
github.com/fatih/color v1.9.0 // indirect
github.com/google/uuid v1.1.1
github.com/hashicorp/terraform-plugin-sdk v1.6.0
github.com/yaegashi/msgraph.go v0.1.1-0.20200209103313-54edc62fbfad
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
github.com/hashicorp/go-getter v1.4.1 // indirect
github.com/hashicorp/go-hclog v0.14.1 // indirect
github.com/hashicorp/go-multierror v1.1.0 // indirect
github.com/hashicorp/go-plugin v1.3.0 // indirect
github.com/hashicorp/go-uuid v1.0.2 // indirect
github.com/hashicorp/go-version v1.2.1 // indirect
github.com/hashicorp/hcl/v2 v2.6.0 // indirect
github.com/hashicorp/terraform-plugin-sdk v1.14.0
github.com/hashicorp/terraform-svchost v0.0.0-20191119180714-d2e4933b9136 // indirect
github.com/hashicorp/yamux v0.0.0-20200609203250-aecfd211c9ce // indirect
github.com/mattn/go-colorable v0.1.7 // indirect
github.com/mitchellh/cli v1.1.1 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.3.2 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/rickb777/date v1.12.5 // indirect
github.com/spf13/afero v1.3.1 // indirect
github.com/ulikunitz/xz v0.5.7 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/yaegashi/msgraph.go v0.1.3
github.com/zclconf/go-cty v1.5.1 // indirect
github.com/zclconf/go-cty-yaml v1.0.2 // indirect
go.opencensus.io v0.22.4 // indirect
golang.org/x/net v0.0.0-20200625001655-4c5254603344 // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect
golang.org/x/text v0.3.3 // indirect
golang.org/x/tools v0.0.0-20200626171337-aa94e735be7f // indirect
google.golang.org/genproto v0.0.0-20200626011028-ee7919e894b5 // indirect
google.golang.org/grpc v1.30.0 // indirect
google.golang.org/protobuf v1.25.0 // indirect
)
356 changes: 346 additions & 10 deletions go.sum

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions msgraph/data_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ func dataGroupResource() *schema.Resource {
return &schema.Resource{
Read: dataGroupRead,
Schema: map[string]*schema.Schema{
"id": &schema.Schema{Type: schema.TypeString, ValidateFunc: validation.IsUUID, Computed: true, Optional: true},
"display_name": &schema.Schema{Type: schema.TypeString, Computed: true},
"mail_nickname": &schema.Schema{Type: schema.TypeString, Computed: true, Optional: true},
"mail_enabled": &schema.Schema{Type: schema.TypeBool, Computed: true},
"security_enabled": &schema.Schema{Type: schema.TypeBool, Computed: true},
"mail": &schema.Schema{Type: schema.TypeString, Computed: true},
"group_types": &schema.Schema{Type: schema.TypeList, Computed: true, Elem: &schema.Schema{Type: schema.TypeString}},
"visibility": &schema.Schema{Type: schema.TypeString, Computed: true},
"id": {Type: schema.TypeString, ValidateFunc: validation.IsUUID, Computed: true, Optional: true},
"display_name": {Type: schema.TypeString, Computed: true},
"mail_nickname": {Type: schema.TypeString, Computed: true, Optional: true},
"mail_enabled": {Type: schema.TypeBool, Computed: true},
"security_enabled": {Type: schema.TypeBool, Computed: true},
"mail": {Type: schema.TypeString, Computed: true},
"group_types": {Type: schema.TypeList, Computed: true, Elem: &schema.Schema{Type: schema.TypeString}},
"visibility": {Type: schema.TypeString, Computed: true},
},
}
}
Expand Down
18 changes: 9 additions & 9 deletions msgraph/data_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ func dataUserResource() *schema.Resource {
return &schema.Resource{
Read: dataUserRead,
Schema: map[string]*schema.Schema{
"id": &schema.Schema{Type: schema.TypeString, ValidateFunc: validation.IsUUID, Computed: true, Optional: true, ConflictsWith: []string{"user_principal_name", "mail_nickname"}},
"user_principal_name": &schema.Schema{Type: schema.TypeString, Computed: true, Optional: true, ConflictsWith: []string{"id", "mail_nickname"}},
"display_name": &schema.Schema{Type: schema.TypeString, Computed: true},
"given_name": &schema.Schema{Type: schema.TypeString, Computed: true},
"surname": &schema.Schema{Type: schema.TypeString, Computed: true},
"mail_nickname": &schema.Schema{Type: schema.TypeString, Computed: true, Optional: true, ConflictsWith: []string{"id", "user_principal_name"}},
"mail": &schema.Schema{Type: schema.TypeString, Computed: true},
"other_mails": &schema.Schema{Type: schema.TypeList, Computed: true, Elem: &schema.Schema{Type: schema.TypeString}},
"account_enabled": &schema.Schema{Type: schema.TypeBool, Computed: true},
"id": {Type: schema.TypeString, ValidateFunc: validation.IsUUID, Computed: true, Optional: true, ConflictsWith: []string{"user_principal_name", "mail_nickname"}},
"user_principal_name": {Type: schema.TypeString, Computed: true, Optional: true, ConflictsWith: []string{"id", "mail_nickname"}},
"display_name": {Type: schema.TypeString, Computed: true},
"given_name": {Type: schema.TypeString, Computed: true},
"surname": {Type: schema.TypeString, Computed: true},
"mail_nickname": {Type: schema.TypeString, Computed: true, Optional: true, ConflictsWith: []string{"id", "user_principal_name"}},
"mail": {Type: schema.TypeString, Computed: true},
"other_mails": {Type: schema.TypeList, Computed: true, Elem: &schema.Schema{Type: schema.TypeString}},
"account_enabled": {Type: schema.TypeBool, Computed: true},
},
}
}
Expand Down
10 changes: 5 additions & 5 deletions msgraph/resource_application password.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ func resourceApplicationPasswordResource() *schema.Resource {
Read: resourceApplicationPasswordRead,
Delete: resourceApplicationPasswordDelete,
Schema: map[string]*schema.Schema{
"application_id": &schema.Schema{Type: schema.TypeString, Required: true, ForceNew: true},
"display_name": &schema.Schema{Type: schema.TypeString, Required: true, ForceNew: true},
"start_date_time": &schema.Schema{Type: schema.TypeString, ValidateFunc: validation.ValidateRFC3339TimeString, Optional: true, Computed: true, ForceNew: true},
"end_date_time": &schema.Schema{Type: schema.TypeString, ValidateFunc: validation.ValidateRFC3339TimeString, Optional: true, Computed: true, ForceNew: true},
"secret_text": &schema.Schema{Type: schema.TypeString, Computed: true, Sensitive: true},
"application_id": {Type: schema.TypeString, Required: true, ForceNew: true},
"display_name": {Type: schema.TypeString, Required: true, ForceNew: true},
"start_date_time": {Type: schema.TypeString, ValidateFunc: validation.ValidateRFC3339TimeString, Optional: true, Computed: true, ForceNew: true},
"end_date_time": {Type: schema.TypeString, ValidateFunc: validation.ValidateRFC3339TimeString, Optional: true, Computed: true, ForceNew: true},
"secret_text": {Type: schema.TypeString, Computed: true, Sensitive: true},
},
}
}
Expand Down
14 changes: 7 additions & 7 deletions msgraph/resource_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ func resourceGroupResource() *schema.Resource {
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"display_name": &schema.Schema{Type: schema.TypeString, Required: true},
"mail_nickname": &schema.Schema{Type: schema.TypeString, Required: true},
"mail_enabled": &schema.Schema{Type: schema.TypeBool, Computed: true},
"security_enabled": &schema.Schema{Type: schema.TypeBool, Computed: true},
"mail": &schema.Schema{Type: schema.TypeString, Computed: true},
"group_types": &schema.Schema{Type: schema.TypeList, Optional: true, Elem: &schema.Schema{Type: schema.TypeString}},
"visibility": &schema.Schema{Type: schema.TypeString, Optional: true},
"display_name": {Type: schema.TypeString, Required: true},
"mail_nickname": {Type: schema.TypeString, Required: true},
"mail_enabled": {Type: schema.TypeBool, Computed: true},
"security_enabled": {Type: schema.TypeBool, Computed: true},
"mail": {Type: schema.TypeString, Computed: true},
"group_types": {Type: schema.TypeList, Optional: true, Elem: &schema.Schema{Type: schema.TypeString}},
"visibility": {Type: schema.TypeString, Optional: true},
},
}
}
Expand Down
4 changes: 2 additions & 2 deletions msgraph/resource_group_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func resourceGroupMemberResource() *schema.Resource {
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"group_id": &schema.Schema{Type: schema.TypeString, Required: true, ForceNew: true},
"member_id": &schema.Schema{Type: schema.TypeString, Required: true, ForceNew: true},
"group_id": {Type: schema.TypeString, Required: true, ForceNew: true},
"member_id": {Type: schema.TypeString, Required: true, ForceNew: true},
},
}
}
Expand Down
20 changes: 10 additions & 10 deletions msgraph/resource_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ func resourceUserResource() *schema.Resource {
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"user_principal_name": &schema.Schema{Type: schema.TypeString, Required: true},
"display_name": &schema.Schema{Type: schema.TypeString, Required: true},
"given_name": &schema.Schema{Type: schema.TypeString, Optional: true},
"surname": &schema.Schema{Type: schema.TypeString, Optional: true},
"mail_nickname": &schema.Schema{Type: schema.TypeString, Required: true},
"mail": &schema.Schema{Type: schema.TypeString, Computed: true},
"other_mails": &schema.Schema{Type: schema.TypeList, Optional: true, Elem: &schema.Schema{Type: schema.TypeString}},
"account_enabled": &schema.Schema{Type: schema.TypeBool, Required: true},
"password": &schema.Schema{Type: schema.TypeString, Computed: true, Optional: true, Sensitive: true},
"force_change_password_next_sign_in": &schema.Schema{Type: schema.TypeBool, Computed: true, Optional: true},
"user_principal_name": {Type: schema.TypeString, Required: true},
"display_name": {Type: schema.TypeString, Required: true},
"given_name": {Type: schema.TypeString, Optional: true},
"surname": {Type: schema.TypeString, Optional: true},
"mail_nickname": {Type: schema.TypeString, Required: true},
"mail": {Type: schema.TypeString, Computed: true},
"other_mails": {Type: schema.TypeList, Optional: true, Elem: &schema.Schema{Type: schema.TypeString}},
"account_enabled": {Type: schema.TypeBool, Required: true},
"password": {Type: schema.TypeString, Computed: true, Optional: true, Sensitive: true},
"force_change_password_next_sign_in": {Type: schema.TypeBool, Computed: true, Optional: true},
},
}
}
Expand Down

0 comments on commit a683208

Please sign in to comment.