-
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.
Filestore enterprise support (#5450)
* Move tier to string * Add note on possible values * Add note for beta-only on enterprise * Starting to move to location * Add precreate * Write state migration * Use location in examples * Use upgrade state function instead of migrate * Fix linter * Update validator test to use location * Update TFV test config to use location
- Loading branch information
Showing
10 changed files
with
285 additions
and
31 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
<%# We have to change the name of 'file' to 'filestore' for magic-modules generation reasons.-%> | ||
import ( | ||
<% if version == "ga" -%> | ||
filestore "google.golang.org/api/file/v1beta1" | ||
<% else -%> | ||
filestore "google.golang.org/api/file/v1" | ||
<% end -%> | ||
) |
2 changes: 1 addition & 1 deletion
2
mmv1/templates/terraform/examples/filestore_instance_basic.tf.erb
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
2 changes: 1 addition & 1 deletion
2
mmv1/templates/terraform/examples/filestore_instance_full.tf.erb
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
17 changes: 17 additions & 0 deletions
17
mmv1/templates/terraform/pre_create/filestore_instance.go.erb
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,17 @@ | ||
if d.Get("location") == "" { | ||
zone, err := getZone(d, config) | ||
if err != nil { | ||
return err | ||
} | ||
err = d.Set("location", zone) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
if strings.Contains(url, "locations//") { | ||
// re-compute url now that location must be set | ||
url, err = replaceVars(d, config, "<%= "{{#{object.__product.name}BasePath}}#{object.create_uri}" -%>") | ||
if err != nil { | ||
return err | ||
} | ||
} |
188 changes: 188 additions & 0 deletions
188
mmv1/templates/terraform/state_migrations/filestore_instance.go.erb
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,188 @@ | ||
func resourceFilestoreInstanceResourceV0() *schema.Resource { | ||
return &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"file_shares": { | ||
Type: schema.TypeList, | ||
Required: true, | ||
Description: `File system shares on the instance. For this version, only a | ||
single file share is supported.`, | ||
MaxItems: 1, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"capacity_gb": { | ||
Type: schema.TypeInt, | ||
Required: true, | ||
Description: `File share capacity in GiB. This must be at least 1024 GiB | ||
for the standard tier, or 2560 GiB for the premium tier.`, | ||
}, | ||
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
Description: `The name of the fileshare (16 characters or less)`, | ||
}, | ||
"nfs_export_options": { | ||
Type: schema.TypeList, | ||
Optional: true, | ||
Description: `Nfs Export Options. There is a limit of 10 export options per file share.`, | ||
MaxItems: 10, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"access_mode": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ValidateFunc: validation.StringInSlice([]string{"READ_ONLY", "READ_WRITE", ""}, false), | ||
Description: `Either READ_ONLY, for allowing only read requests on the exported directory, | ||
or READ_WRITE, for allowing both read and write requests. The default is READ_WRITE. Default value: "READ_WRITE" Possible values: ["READ_ONLY", "READ_WRITE"]`, | ||
Default: "READ_WRITE", | ||
}, | ||
"anon_gid": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Description: `An integer representing the anonymous group id with a default value of 65534. | ||
Anon_gid may only be set with squashMode of ROOT_SQUASH. An error will be returned | ||
if this field is specified for other squashMode settings.`, | ||
}, | ||
"anon_uid": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
Description: `An integer representing the anonymous user id with a default value of 65534. | ||
Anon_uid may only be set with squashMode of ROOT_SQUASH. An error will be returned | ||
if this field is specified for other squashMode settings.`, | ||
}, | ||
"ip_ranges": { | ||
Type: schema.TypeList, | ||
Optional: true, | ||
Description: `List of either IPv4 addresses, or ranges in CIDR notation which may mount the file share. | ||
Overlapping IP ranges are not allowed, both within and across NfsExportOptions. An error will be returned. | ||
The limit is 64 IP ranges/addresses for each FileShareConfig among all NfsExportOptions.`, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
}, | ||
}, | ||
"squash_mode": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ValidateFunc: validation.StringInSlice([]string{"NO_ROOT_SQUASH", "ROOT_SQUASH", ""}, false), | ||
Description: `Either NO_ROOT_SQUASH, for allowing root access on the exported directory, or ROOT_SQUASH, | ||
for not allowing root access. The default is NO_ROOT_SQUASH. Default value: "NO_ROOT_SQUASH" Possible values: ["NO_ROOT_SQUASH", "ROOT_SQUASH"]`, | ||
Default: "NO_ROOT_SQUASH", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: `The resource name of the instance.`, | ||
}, | ||
"networks": { | ||
Type: schema.TypeList, | ||
Required: true, | ||
ForceNew: true, | ||
Description: `VPC networks to which the instance is connected. For this version, | ||
only a single network is supported.`, | ||
MinItems: 1, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"modes": { | ||
Type: schema.TypeList, | ||
Required: true, | ||
ForceNew: true, | ||
Description: `IP versions for which the instance has | ||
IP addresses assigned. Possible values: ["ADDRESS_MODE_UNSPECIFIED", "MODE_IPV4", "MODE_IPV6"]`, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
ValidateFunc: validation.StringInSlice([]string{"ADDRESS_MODE_UNSPECIFIED", "MODE_IPV4", "MODE_IPV6"}, false), | ||
}, | ||
}, | ||
"network": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
Description: `The name of the GCE VPC network to which the | ||
instance is connected.`, | ||
}, | ||
"connect_mode": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ForceNew: true, | ||
ValidateFunc: validation.StringInSlice([]string{"DIRECT_PEERING", "PRIVATE_SERVICE_ACCESS", ""}, false), | ||
Description: `The network connect mode of the Filestore instance. | ||
If not provided, the connect mode defaults to | ||
DIRECT_PEERING. Default value: "DIRECT_PEERING" Possible values: ["DIRECT_PEERING", "PRIVATE_SERVICE_ACCESS"]`, | ||
Default: "DIRECT_PEERING", | ||
}, | ||
"reserved_ip_range": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Optional: true, | ||
Description: `A /29 CIDR block that identifies the range of IP | ||
addresses reserved for this instance.`, | ||
}, | ||
"ip_addresses": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Description: `A list of IPv4 or IPv6 addresses.`, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
"tier": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
ValidateFunc: validation.StringInSlice([]string{"TIER_UNSPECIFIED", "STANDARD", "PREMIUM", "BASIC_HDD", "BASIC_SSD", "HIGH_SCALE_SSD"}, false), | ||
Description: `The service tier of the instance. Possible values: ["TIER_UNSPECIFIED", "STANDARD", "PREMIUM", "BASIC_HDD", "BASIC_SSD", "HIGH_SCALE_SSD"]`, | ||
}, | ||
"zone": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
Description: `The name of the Filestore zone of the instance.`, | ||
}, | ||
"description": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: `A description of the instance.`, | ||
}, | ||
"labels": { | ||
Type: schema.TypeMap, | ||
Optional: true, | ||
Description: `Resource labels to represent user-provided metadata.`, | ||
Elem: &schema.Schema{Type: schema.TypeString}, | ||
}, | ||
"create_time": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: `Creation timestamp in RFC3339 text format.`, | ||
}, | ||
"etag": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: `Server-specified ETag for the instance resource to prevent | ||
simultaneous updates from overwriting each other.`, | ||
}, | ||
"project": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Computed: true, | ||
ForceNew: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func resourceFilestoreInstanceUpgradeV0(_ context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { | ||
log.Printf("[DEBUG] Attributes before migration: %#v", rawState) | ||
|
||
rawState["location"] = rawState["zone"] | ||
log.Printf("[DEBUG] Attributes after migration: %#v", rawState) | ||
return rawState, nil | ||
} |
Oops, something went wrong.