-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy terraform resources and data_sources from magic modules (#556)
Merged PR #556.
- Loading branch information
1 parent
355fbf1
commit 8d2f6ea
Showing
132 changed files
with
34,167 additions
and
3 deletions.
There are no files selected for viewing
Submodule terraform
updated
from 51e63b to 40ebce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
provider/terraform/data_sources/data_source_compute_lb_ip_ranges.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package google | ||
|
||
import ( | ||
"github.com/hashicorp/terraform/helper/schema" | ||
) | ||
|
||
func dataSourceGoogleComputeLbIpRanges() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceGoogleComputeLbIpRangesRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"network": { | ||
Type: schema.TypeList, | ||
Elem: &schema.Schema{Type: schema.TypeString}, | ||
Computed: true, | ||
}, | ||
"http_ssl_tcp_internal": { | ||
Type: schema.TypeList, | ||
Elem: &schema.Schema{Type: schema.TypeString}, | ||
Computed: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceGoogleComputeLbIpRangesRead(d *schema.ResourceData, meta interface{}) error { | ||
d.SetId("compute-lb-ip-ranges") | ||
|
||
// https://cloud.google.com/compute/docs/load-balancing/health-checks#health_check_source_ips_and_firewall_rules | ||
|
||
networkIpRanges := []string{ | ||
"209.85.152.0/22", | ||
"209.85.204.0/22", | ||
"35.191.0.0/16", | ||
} | ||
d.Set("network", networkIpRanges) | ||
|
||
httpSslTcpInternalRanges := []string{ | ||
"130.211.0.0/22", | ||
"35.191.0.0/16", | ||
} | ||
d.Set("http_ssl_tcp_internal", httpSslTcpInternalRanges) | ||
|
||
return nil | ||
} |
67 changes: 67 additions & 0 deletions
67
provider/terraform/data_sources/data_source_container_registry_image.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform/helper/schema" | ||
) | ||
|
||
func dataSourceGoogleContainerImage() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: containerRegistryImageRead, | ||
Schema: map[string]*schema.Schema{ | ||
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"tag": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
"digest": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
"region": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
"project": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
}, | ||
"image_url": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func containerRegistryImageRead(d *schema.ResourceData, meta interface{}) error { | ||
config := meta.(*Config) | ||
project, err := getProject(d, config) | ||
if err != nil { | ||
return err | ||
} | ||
d.Set("project", project) | ||
region, ok := d.GetOk("region") | ||
var url_base string | ||
if ok && region != nil && region != "" { | ||
url_base = fmt.Sprintf("%s.gcr.io/%s", region, project) | ||
} else { | ||
url_base = fmt.Sprintf("gcr.io/%s", project) | ||
} | ||
tag, t_ok := d.GetOk("tag") | ||
digest, d_ok := d.GetOk("digest") | ||
if t_ok && tag != nil && tag != "" { | ||
d.Set("image_url", fmt.Sprintf("%s/%s:%s", url_base, d.Get("name").(string), tag)) | ||
} else if d_ok && digest != nil && digest != "" { | ||
d.Set("image_url", fmt.Sprintf("%s/%s@%s", url_base, d.Get("name").(string), digest)) | ||
} else { | ||
d.Set("image_url", fmt.Sprintf("%s/%s", url_base, d.Get("name").(string))) | ||
} | ||
d.SetId(d.Get("image_url").(string)) | ||
return nil | ||
} |
45 changes: 45 additions & 0 deletions
45
provider/terraform/data_sources/data_source_container_registry_repository.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform/helper/schema" | ||
) | ||
|
||
func dataSourceGoogleContainerRepo() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: containerRegistryRepoRead, | ||
Schema: map[string]*schema.Schema{ | ||
"region": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
"project": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
}, | ||
"repository_url": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func containerRegistryRepoRead(d *schema.ResourceData, meta interface{}) error { | ||
config := meta.(*Config) | ||
project, err := getProject(d, config) | ||
if err != nil { | ||
return err | ||
} | ||
d.Set("project", project) | ||
region, ok := d.GetOk("region") | ||
if ok && region != nil && region != "" { | ||
d.Set("repository_url", fmt.Sprintf("%s.gcr.io/%s", region, project)) | ||
} else { | ||
d.Set("repository_url", fmt.Sprintf("gcr.io/%s", project)) | ||
} | ||
d.SetId(d.Get("repository_url").(string)) | ||
return nil | ||
} |
65 changes: 65 additions & 0 deletions
65
provider/terraform/data_sources/data_source_dns_managed_zone.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package google | ||
|
||
import "github.com/hashicorp/terraform/helper/schema" | ||
|
||
func dataSourceDnsManagedZone() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceDnsManagedZoneRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"dns_name": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"name": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
|
||
"description": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"name_servers": &schema.Schema{ | ||
Type: schema.TypeSet, | ||
Computed: true, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
}, | ||
}, | ||
|
||
// Google Cloud DNS ManagedZone resources do not have a SelfLink attribute. | ||
|
||
"project": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceDnsManagedZoneRead(d *schema.ResourceData, meta interface{}) error { | ||
config := meta.(*Config) | ||
|
||
d.SetId(d.Get("name").(string)) | ||
|
||
project, err := getProject(d, config) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
zone, err := config.clientDns.ManagedZones.Get( | ||
project, d.Id()).Do() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
d.Set("name_servers", zone.NameServers) | ||
d.Set("name", zone.Name) | ||
d.Set("dns_name", zone.DnsName) | ||
d.Set("description", zone.Description) | ||
|
||
return nil | ||
} |
55 changes: 55 additions & 0 deletions
55
provider/terraform/data_sources/data_source_google_active_folder.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
|
||
"github.com/hashicorp/terraform/helper/schema" | ||
resourceManagerV2Beta1 "google.golang.org/api/cloudresourcemanager/v2beta1" | ||
) | ||
|
||
func dataSourceGoogleActiveFolder() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceGoogleActiveFolderRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"parent": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"display_name": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"name": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceGoogleActiveFolderRead(d *schema.ResourceData, meta interface{}) error { | ||
config := meta.(*Config) | ||
|
||
parent := d.Get("parent").(string) | ||
displayName := d.Get("display_name").(string) | ||
|
||
queryString := fmt.Sprintf("lifecycleState=ACTIVE AND parent=%s AND displayName=%s", parent, url.QueryEscape(displayName)) | ||
searchRequest := &resourceManagerV2Beta1.SearchFoldersRequest{ | ||
Query: queryString, | ||
} | ||
searchResponse, err := config.clientResourceManagerV2Beta1.Folders.Search(searchRequest).Do() | ||
if err != nil { | ||
return handleNotFoundError(err, d, fmt.Sprintf("Folder Not Found : %s", displayName)) | ||
} | ||
|
||
for _, folder := range searchResponse.Folders { | ||
if folder.DisplayName == displayName { | ||
d.SetId(folder.Name) | ||
d.Set("name", folder.Name) | ||
return nil | ||
} | ||
} | ||
return fmt.Errorf("Folder not found") | ||
} |
Oops, something went wrong.