mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-09 11:38:29 +00:00
Remove deprecated resources for 1.0.0.
In advance of 1.0.0, let's take the opportunity to remove the fields on resources that have been deprecated for a while.
This commit is contained in:
parent
0b4158d1ea
commit
f2f276ea0b
|
@ -91,7 +91,7 @@ func resourceComputeGlobalForwardingRule() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Deprecated: "Please remove this attribute (it was never used)",
|
Removed: "Please remove this attribute (it was never used)",
|
||||||
},
|
},
|
||||||
|
|
||||||
"self_link": &schema.Schema{
|
"self_link": &schema.Schema{
|
||||||
|
|
|
@ -289,7 +289,7 @@ func resourceComputeInstance() *schema.Resource {
|
||||||
|
|
||||||
"network_interface": &schema.Schema{
|
"network_interface": &schema.Schema{
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
|
@ -374,7 +374,7 @@ func resourceComputeInstance() *schema.Resource {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Deprecated: "Please use network_interface",
|
Removed: "Please use network_interface",
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"source": &schema.Schema{
|
"source": &schema.Schema{
|
||||||
|
@ -748,51 +748,8 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
|
||||||
disks = append(disks, &disk)
|
disks = append(disks, &disk)
|
||||||
}
|
}
|
||||||
|
|
||||||
networksCount := d.Get("network.#").(int)
|
|
||||||
networkInterfacesCount := d.Get("network_interface.#").(int)
|
|
||||||
|
|
||||||
if networksCount > 0 && networkInterfacesCount > 0 {
|
|
||||||
return fmt.Errorf("Error: cannot define both networks and network_interfaces.")
|
|
||||||
}
|
|
||||||
if networksCount == 0 && networkInterfacesCount == 0 {
|
|
||||||
return fmt.Errorf("Error: Must define at least one network_interface.")
|
|
||||||
}
|
|
||||||
|
|
||||||
var networkInterfaces []*computeBeta.NetworkInterface
|
|
||||||
|
|
||||||
if networksCount > 0 {
|
|
||||||
// TODO: Delete this block when removing network { }
|
|
||||||
// Build up the list of networkInterfaces
|
// Build up the list of networkInterfaces
|
||||||
networkInterfaces = make([]*computeBeta.NetworkInterface, 0, networksCount)
|
networkInterfaces := make([]*computeBeta.NetworkInterface, 0, networkInterfacesCount)
|
||||||
for i := 0; i < networksCount; i++ {
|
|
||||||
prefix := fmt.Sprintf("network.%d", i)
|
|
||||||
// Load up the name of this network
|
|
||||||
networkName := d.Get(prefix + ".source").(string)
|
|
||||||
network, err := config.clientCompute.Networks.Get(
|
|
||||||
project, networkName).Do()
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf(
|
|
||||||
"Error loading network '%s': %s",
|
|
||||||
networkName, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build the networkInterface
|
|
||||||
var iface computeBeta.NetworkInterface
|
|
||||||
iface.AccessConfigs = []*computeBeta.AccessConfig{
|
|
||||||
&computeBeta.AccessConfig{
|
|
||||||
Type: "ONE_TO_ONE_NAT",
|
|
||||||
NatIP: d.Get(prefix + ".address").(string),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
iface.Network = network.SelfLink
|
|
||||||
|
|
||||||
networkInterfaces = append(networkInterfaces, &iface)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if networkInterfacesCount > 0 {
|
|
||||||
// Build up the list of networkInterfaces
|
|
||||||
networkInterfaces = make([]*computeBeta.NetworkInterface, 0, networkInterfacesCount)
|
|
||||||
for i := 0; i < networkInterfacesCount; i++ {
|
for i := 0; i < networkInterfacesCount; i++ {
|
||||||
prefix := fmt.Sprintf("network_interface.%d", i)
|
prefix := fmt.Sprintf("network_interface.%d", i)
|
||||||
// Load up the name of this network_interface
|
// Load up the name of this network_interface
|
||||||
|
@ -837,7 +794,6 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
|
||||||
|
|
||||||
networkInterfaces = append(networkInterfaces, &iface)
|
networkInterfaces = append(networkInterfaces, &iface)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
serviceAccountsCount := d.Get("service_account.#").(int)
|
serviceAccountsCount := d.Get("service_account.#").(int)
|
||||||
serviceAccounts := make([]*computeBeta.ServiceAccount, 0, serviceAccountsCount)
|
serviceAccounts := make([]*computeBeta.ServiceAccount, 0, serviceAccountsCount)
|
||||||
|
@ -992,48 +948,12 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error
|
||||||
}
|
}
|
||||||
d.Set("service_account", serviceAccounts)
|
d.Set("service_account", serviceAccounts)
|
||||||
|
|
||||||
networksCount := d.Get("network.#").(int)
|
|
||||||
networkInterfacesCount := d.Get("network_interface.#").(int)
|
|
||||||
|
|
||||||
if networksCount > 0 && networkInterfacesCount > 0 {
|
|
||||||
return fmt.Errorf("Error: cannot define both networks and network_interfaces.")
|
|
||||||
}
|
|
||||||
if networksCount == 0 && networkInterfacesCount == 0 {
|
|
||||||
return fmt.Errorf("Error: Must define at least one network_interface.")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the networks
|
// Set the networks
|
||||||
// Use the first external IP found for the default connection info.
|
// Use the first external IP found for the default connection info.
|
||||||
externalIP := ""
|
externalIP := ""
|
||||||
internalIP := ""
|
internalIP := ""
|
||||||
networks := make([]map[string]interface{}, 0, 1)
|
|
||||||
if networksCount > 0 {
|
|
||||||
// TODO: Remove this when realizing deprecation of .network
|
|
||||||
for i, iface := range instance.NetworkInterfaces {
|
|
||||||
var natIP string
|
|
||||||
for _, config := range iface.AccessConfigs {
|
|
||||||
if config.Type == "ONE_TO_ONE_NAT" {
|
|
||||||
natIP = config.NatIP
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if externalIP == "" && natIP != "" {
|
|
||||||
externalIP = natIP
|
|
||||||
}
|
|
||||||
|
|
||||||
network := make(map[string]interface{})
|
|
||||||
network["name"] = iface.Name
|
|
||||||
network["external_address"] = natIP
|
|
||||||
network["internal_address"] = iface.NetworkIP
|
|
||||||
network["source"] = d.Get(fmt.Sprintf("network.%d.source", i))
|
|
||||||
networks = append(networks, network)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
d.Set("network", networks)
|
|
||||||
|
|
||||||
networkInterfaces := make([]map[string]interface{}, 0, 1)
|
networkInterfaces := make([]map[string]interface{}, 0, 1)
|
||||||
if networkInterfacesCount > 0 {
|
|
||||||
for i, iface := range instance.NetworkInterfaces {
|
for i, iface := range instance.NetworkInterfaces {
|
||||||
// The first non-empty ip is left in natIP
|
// The first non-empty ip is left in natIP
|
||||||
var natIP string
|
var natIP string
|
||||||
|
@ -1068,8 +988,6 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error
|
||||||
"alias_ip_range": flattenAliasIpRange(iface.AliasIpRanges),
|
"alias_ip_range": flattenAliasIpRange(iface.AliasIpRanges),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
d.Set("network_interface", networkInterfaces)
|
|
||||||
|
|
||||||
// Fall back on internal ip if there is no external ip. This makes sense in the situation where
|
// Fall back on internal ip if there is no external ip. This makes sense in the situation where
|
||||||
// terraform is being used on a cloud instance and can therefore access the instances it creates
|
// terraform is being used on a cloud instance and can therefore access the instances it creates
|
||||||
|
@ -1315,7 +1233,6 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
|
||||||
}
|
}
|
||||||
|
|
||||||
networkInterfacesCount := d.Get("network_interface.#").(int)
|
networkInterfacesCount := d.Get("network_interface.#").(int)
|
||||||
if networkInterfacesCount > 0 {
|
|
||||||
// Sanity check
|
// Sanity check
|
||||||
if networkInterfacesCount != len(instance.NetworkInterfaces) {
|
if networkInterfacesCount != len(instance.NetworkInterfaces) {
|
||||||
return fmt.Errorf("Instance had unexpected number of network interfaces: %d", len(instance.NetworkInterfaces))
|
return fmt.Errorf("Instance had unexpected number of network interfaces: %d", len(instance.NetworkInterfaces))
|
||||||
|
@ -1373,7 +1290,6 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// We made it, disable partial mode
|
// We made it, disable partial mode
|
||||||
d.Partial(false)
|
d.Partial(false)
|
||||||
|
|
|
@ -28,11 +28,7 @@ func resourceComputeNetwork() *schema.Resource {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
/* Ideally this would default to true as per the API, but that would cause
|
Default: true,
|
||||||
existing Terraform configs which have not been updated to report this as
|
|
||||||
a change. Perhaps we can bump this for a minor release bump rather than
|
|
||||||
a point release.
|
|
||||||
Default: false, */
|
|
||||||
ConflictsWith: []string{"ipv4_range"},
|
ConflictsWith: []string{"ipv4_range"},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -51,7 +47,7 @@ func resourceComputeNetwork() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Deprecated: "Please use google_compute_subnetwork resources instead.",
|
Removed: "Please use google_compute_subnetwork resources instead.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"project": &schema.Schema{
|
"project": &schema.Schema{
|
||||||
|
@ -76,32 +72,15 @@ func resourceComputeNetworkCreate(d *schema.ResourceData, meta interface{}) erro
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Possible modes:
|
|
||||||
// - 1 Legacy mode - Create a network in the legacy mode. ipv4_range is set. auto_create_subnetworks must not be
|
|
||||||
// set (enforced by ConflictsWith schema attribute)
|
|
||||||
// - 2 Distributed Mode - Create a new generation network that supports subnetworks:
|
|
||||||
// - 2.a - Auto subnet mode - auto_create_subnetworks = true, Google will generate 1 subnetwork per region
|
|
||||||
// - 2.b - Custom subnet mode - auto_create_subnetworks = false & ipv4_range not set,
|
|
||||||
//
|
|
||||||
autoCreateSubnetworks := d.Get("auto_create_subnetworks").(bool)
|
|
||||||
|
|
||||||
// Build the network parameter
|
// Build the network parameter
|
||||||
network := &compute.Network{
|
network := &compute.Network{
|
||||||
Name: d.Get("name").(string),
|
Name: d.Get("name").(string),
|
||||||
AutoCreateSubnetworks: autoCreateSubnetworks,
|
AutoCreateSubnetworks: d.Get("auto_create_subnetworks").(bool),
|
||||||
Description: d.Get("description").(string),
|
Description: d.Get("description").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := d.GetOk("ipv4_range"); ok {
|
// make sure AutoCreateSubnetworks field is included in request
|
||||||
log.Printf("[DEBUG] Setting IPv4Range (%#v) for legacy network mode", v.(string))
|
|
||||||
network.IPv4Range = v.(string)
|
|
||||||
} else {
|
|
||||||
// custom subnet mode, so make sure AutoCreateSubnetworks field is included in request otherwise
|
|
||||||
// google will create a network in legacy mode.
|
|
||||||
network.ForceSendFields = []string{"AutoCreateSubnetworks"}
|
network.ForceSendFields = []string{"AutoCreateSubnetworks"}
|
||||||
}
|
|
||||||
|
|
||||||
log.Printf("[DEBUG] Network insert request: %#v", network)
|
log.Printf("[DEBUG] Network insert request: %#v", network)
|
||||||
op, err := config.clientCompute.Networks.Insert(
|
op, err := config.clientCompute.Networks.Insert(
|
||||||
project, network).Do()
|
project, network).Do()
|
||||||
|
@ -136,7 +115,6 @@ func resourceComputeNetworkRead(d *schema.ResourceData, meta interface{}) error
|
||||||
|
|
||||||
d.Set("gateway_ipv4", network.GatewayIPv4)
|
d.Set("gateway_ipv4", network.GatewayIPv4)
|
||||||
d.Set("self_link", network.SelfLink)
|
d.Set("self_link", network.SelfLink)
|
||||||
d.Set("ipv4_range", network.IPv4Range)
|
|
||||||
d.Set("name", network.Name)
|
d.Set("name", network.Name)
|
||||||
d.Set("auto_create_subnetworks", network.AutoCreateSubnetworks)
|
d.Set("auto_create_subnetworks", network.AutoCreateSubnetworks)
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ func resourceContainerCluster() *schema.Resource {
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Deprecated: "Use node_count instead",
|
Removed: "Use node_count instead",
|
||||||
},
|
},
|
||||||
|
|
||||||
"node_count": {
|
"node_count": {
|
||||||
|
@ -391,16 +391,7 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er
|
||||||
for i := 0; i < nodePoolsCount; i++ {
|
for i := 0; i < nodePoolsCount; i++ {
|
||||||
prefix := fmt.Sprintf("node_pool.%d", i)
|
prefix := fmt.Sprintf("node_pool.%d", i)
|
||||||
|
|
||||||
nodeCount := 0
|
nodeCount := d.GetOk(prefix + ".node_count")
|
||||||
if initialNodeCount, ok := d.GetOk(prefix + ".initial_node_count"); ok {
|
|
||||||
nodeCount = initialNodeCount.(int)
|
|
||||||
}
|
|
||||||
if nc, ok := d.GetOk(prefix + ".node_count"); ok {
|
|
||||||
if nodeCount != 0 {
|
|
||||||
return fmt.Errorf("Cannot set both initial_node_count and node_count on node pool %d", i)
|
|
||||||
}
|
|
||||||
nodeCount = nc.(int)
|
|
||||||
}
|
|
||||||
if nodeCount == 0 {
|
if nodeCount == 0 {
|
||||||
return fmt.Errorf("Node pool %d cannot be set with 0 node count", i)
|
return fmt.Errorf("Node pool %d cannot be set with 0 node count", i)
|
||||||
}
|
}
|
||||||
|
@ -759,7 +750,6 @@ func flattenClusterNodePools(d *schema.ResourceData, config *Config, c []*contai
|
||||||
nodePool := map[string]interface{}{
|
nodePool := map[string]interface{}{
|
||||||
"name": np.Name,
|
"name": np.Name,
|
||||||
"name_prefix": d.Get(fmt.Sprintf("node_pool.%d.name_prefix", i)),
|
"name_prefix": d.Get(fmt.Sprintf("node_pool.%d.name_prefix", i)),
|
||||||
"initial_node_count": np.InitialNodeCount,
|
|
||||||
"node_count": size / len(np.InstanceGroupUrls),
|
"node_count": size / len(np.InstanceGroupUrls),
|
||||||
"node_config": flattenNodeConfig(np.Config),
|
"node_config": flattenNodeConfig(np.Config),
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ func resourceStorageBucket() *schema.Resource {
|
||||||
|
|
||||||
"predefined_acl": &schema.Schema{
|
"predefined_acl": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Deprecated: "Please use resource \"storage_bucket_acl.predefined_acl\" instead.",
|
Removed: "Please use resource \"storage_bucket_acl.predefined_acl\" instead.",
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
@ -264,12 +264,7 @@ func resourceStorageBucketCreate(d *schema.ResourceData, meta interface{}) error
|
||||||
var res *storage.Bucket
|
var res *storage.Bucket
|
||||||
|
|
||||||
err = resource.Retry(1*time.Minute, func() *resource.RetryError {
|
err = resource.Retry(1*time.Minute, func() *resource.RetryError {
|
||||||
call := config.clientStorage.Buckets.Insert(project, sb)
|
res, err := config.clientStorage.Buckets.Insert(project, sb).Do()
|
||||||
if v, ok := d.GetOk("predefined_acl"); ok {
|
|
||||||
call = call.PredefinedAcl(v.(string))
|
|
||||||
}
|
|
||||||
|
|
||||||
res, err = call.Do()
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ func resourceStorageBucketObject() *schema.Resource {
|
||||||
|
|
||||||
"predefined_acl": &schema.Schema{
|
"predefined_acl": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Deprecated: "Please use resource \"storage_object_acl.predefined_acl\" instead.",
|
Removed: "Please use resource \"storage_object_acl.predefined_acl\" instead.",
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
@ -157,9 +157,6 @@ func resourceStorageBucketObjectCreate(d *schema.ResourceData, meta interface{})
|
||||||
insertCall := objectsService.Insert(bucket, object)
|
insertCall := objectsService.Insert(bucket, object)
|
||||||
insertCall.Name(name)
|
insertCall.Name(name)
|
||||||
insertCall.Media(media)
|
insertCall.Media(media)
|
||||||
if v, ok := d.GetOk("predefined_acl"); ok {
|
|
||||||
insertCall.PredefinedAcl(v.(string))
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := insertCall.Do()
|
_, err := insertCall.Do()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user