Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon FXx ONTAP File System HA Pair update #34993

Merged
15 changes: 15 additions & 0 deletions .changelog/34993.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```release-note:enhancement
resource/aws_fsx_ontap_file_system: Increase maximum value of `disk_iops_configuration.iops` to `2400000`
```

```release-note:enhancement
resource/aws_fsx_ontap_file_system: `throughput_capacity` is Optional
```

```release-note:enhancement
resource/aws_fsx_ontap_file_system: Add `ha_pairs` and `throughput_capacity_per_ha_pair` arguments
```

```release-note:enhancement
data-source/aws_fsx_ontap_file_system: Add `ha_pairs` and `throughput_capacity_per_ha_pair` attributes
```
45 changes: 41 additions & 4 deletions internal/service/fsx/ontap_file_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func ResourceONTAPFileSystem() *schema.Resource {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntBetween(0, 160000),
ValidateFunc: validation.IntBetween(0, 2400000),
},
"mode": {
Type: schema.TypeString,
Expand Down Expand Up @@ -151,6 +151,13 @@ func ResourceONTAPFileSystem() *schema.Resource {
Sensitive: true,
ValidateFunc: validation.StringLenBetween(8, 50),
},
"ha_pairs": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.IntBetween(1, 6),
},
"kms_key_id": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -212,8 +219,16 @@ func ResourceONTAPFileSystem() *schema.Resource {
names.AttrTagsAll: tftags.TagsSchemaComputed(),
"throughput_capacity": {
Type: schema.TypeInt,
Required: true,
Optional: true,
ValidateFunc: validation.IntInSlice([]int{128, 256, 512, 1024, 2048, 4096}),
ExactlyOneOf: []string{"throughput_capacity", "throughput_capacity_per_ha_pair"},
},
"throughput_capacity_per_ha_pair": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
ValidateFunc: validation.IntInSlice([]int{3072, 6144}),
ExactlyOneOf: []string{"throughput_capacity", "throughput_capacity_per_ha_pair"},
},
"vpc_id": {
Type: schema.TypeString,
Expand Down Expand Up @@ -245,7 +260,6 @@ func resourceONTAPFileSystemCreate(ctx context.Context, d *schema.ResourceData,
AutomaticBackupRetentionDays: aws.Int64(int64(d.Get("automatic_backup_retention_days").(int))),
DeploymentType: aws.String(d.Get("deployment_type").(string)),
PreferredSubnetId: aws.String(d.Get("preferred_subnet_id").(string)),
ThroughputCapacity: aws.Int64(int64(d.Get("throughput_capacity").(int))),
},
StorageCapacity: aws.Int64(int64(d.Get("storage_capacity").(int))),
StorageType: aws.String(d.Get("storage_type").(string)),
Expand All @@ -269,6 +283,17 @@ func resourceONTAPFileSystemCreate(ctx context.Context, d *schema.ResourceData,
input.OntapConfiguration.FsxAdminPassword = aws.String(v.(string))
}

if v, ok := d.GetOk("ha_pairs"); ok {
v := int64(v.(int))
input.OntapConfiguration.HAPairs = aws.Int64(v)

if v > 1 {
if v, ok := d.GetOk("throughput_capacity_per_ha_pair"); ok {
input.OntapConfiguration.ThroughputCapacityPerHAPair = aws.Int64(int64(v.(int)))
}
}
}

if v, ok := d.GetOk("kms_key_id"); ok {
input.KmsKeyId = aws.String(v.(string))
}
Expand All @@ -281,6 +306,10 @@ func resourceONTAPFileSystemCreate(ctx context.Context, d *schema.ResourceData,
input.SecurityGroupIds = flex.ExpandStringSet(v.(*schema.Set))
}

if v, ok := d.GetOk("throughput_capacity"); ok {
input.OntapConfiguration.ThroughputCapacity = aws.Int64(int64(v.(int)))
}

if v, ok := d.GetOk("weekly_maintenance_start_time"); ok {
input.OntapConfiguration.WeeklyMaintenanceStartTime = aws.String(v.(string))
}
Expand Down Expand Up @@ -331,6 +360,8 @@ func resourceONTAPFileSystemRead(ctx context.Context, d *schema.ResourceData, me
return sdkdiag.AppendErrorf(diags, "setting endpoints: %s", err)
}
d.Set("fsx_admin_password", d.Get("fsx_admin_password").(string))
haPairs := aws.Int64Value(ontapConfig.HAPairs)
d.Set("ha_pairs", haPairs)
d.Set("kms_key_id", filesystem.KmsKeyId)
d.Set("network_interface_ids", aws.StringValueSlice(filesystem.NetworkInterfaceIds))
d.Set("owner_id", filesystem.OwnerId)
Expand All @@ -339,7 +370,13 @@ func resourceONTAPFileSystemRead(ctx context.Context, d *schema.ResourceData, me
d.Set("storage_capacity", filesystem.StorageCapacity)
d.Set("storage_type", filesystem.StorageType)
d.Set("subnet_ids", aws.StringValueSlice(filesystem.SubnetIds))
d.Set("throughput_capacity", ontapConfig.ThroughputCapacity)
if haPairs > 1 {
d.Set("throughput_capacity", nil)
d.Set("throughput_capacity_per_ha_pair", ontapConfig.ThroughputCapacityPerHAPair)
} else {
d.Set("throughput_capacity", ontapConfig.ThroughputCapacity)
d.Set("throughput_capacity_per_ha_pair", nil)
}
d.Set("vpc_id", filesystem.VpcId)
d.Set("weekly_maintenance_start_time", ontapConfig.WeeklyMaintenanceStartTime)

Expand Down
38 changes: 28 additions & 10 deletions internal/service/fsx/ontap_file_system_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ func DataSourceONTAPFileSystem() *schema.Resource {
},
},
},
"ha_pairs": {
Type: schema.TypeInt,
Computed: true,
},
"id": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -148,6 +152,10 @@ func DataSourceONTAPFileSystem() *schema.Resource {
Type: schema.TypeInt,
Computed: true,
},
"throughput_capacity_per_ha_pair": {
Type: schema.TypeInt,
Computed: true,
},
"vpc_id": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -178,30 +186,40 @@ func dataSourceONTAPFileSystemRead(ctx context.Context, d *schema.ResourceData,
return sdkdiag.AppendErrorf(diags, "reading FSx for NetApp ONTAP File System (%s): %s", id, err)
}

ontapConfig := filesystem.OntapConfiguration

d.SetId(aws.StringValue(filesystem.FileSystemId))
d.Set("arn", filesystem.ResourceARN)
d.Set("automatic_backup_retention_days", filesystem.OntapConfiguration.AutomaticBackupRetentionDays)
d.Set("daily_automatic_backup_start_time", filesystem.OntapConfiguration.DailyAutomaticBackupStartTime)
d.Set("deployment_type", filesystem.OntapConfiguration.DeploymentType)
if err := d.Set("disk_iops_configuration", flattenOntapFileDiskIopsConfiguration(filesystem.OntapConfiguration.DiskIopsConfiguration)); err != nil {
d.Set("automatic_backup_retention_days", ontapConfig.AutomaticBackupRetentionDays)
d.Set("daily_automatic_backup_start_time", ontapConfig.DailyAutomaticBackupStartTime)
d.Set("deployment_type", ontapConfig.DeploymentType)
if err := d.Set("disk_iops_configuration", flattenOntapFileDiskIopsConfiguration(ontapConfig.DiskIopsConfiguration)); err != nil {
return sdkdiag.AppendErrorf(diags, "setting disk_iops_configuration: %s", err)
}
d.Set("dns_name", filesystem.DNSName)
d.Set("endpoint_ip_address_range", filesystem.OntapConfiguration.EndpointIpAddressRange)
if err := d.Set("endpoints", flattenOntapFileSystemEndpoints(filesystem.OntapConfiguration.Endpoints)); err != nil {
d.Set("endpoint_ip_address_range", ontapConfig.EndpointIpAddressRange)
if err := d.Set("endpoints", flattenOntapFileSystemEndpoints(ontapConfig.Endpoints)); err != nil {
return sdkdiag.AppendErrorf(diags, "setting endpoints: %s", err)
}
haPairs := aws.Int64Value(ontapConfig.HAPairs)
d.Set("ha_pairs", haPairs)
d.Set("kms_key_id", filesystem.KmsKeyId)
d.Set("network_interface_ids", aws.StringValueSlice(filesystem.NetworkInterfaceIds))
d.Set("owner_id", filesystem.OwnerId)
d.Set("preferred_subnet_id", filesystem.OntapConfiguration.PreferredSubnetId)
d.Set("route_table_ids", aws.StringValueSlice(filesystem.OntapConfiguration.RouteTableIds))
d.Set("preferred_subnet_id", ontapConfig.PreferredSubnetId)
d.Set("route_table_ids", aws.StringValueSlice(ontapConfig.RouteTableIds))
d.Set("storage_capacity", filesystem.StorageCapacity)
d.Set("storage_type", filesystem.StorageType)
d.Set("subnet_ids", aws.StringValueSlice(filesystem.SubnetIds))
d.Set("throughput_capacity", filesystem.OntapConfiguration.ThroughputCapacity)
if haPairs > 1 {
d.Set("throughput_capacity", nil)
d.Set("throughput_capacity_per_ha_pair", ontapConfig.ThroughputCapacityPerHAPair)
} else {
d.Set("throughput_capacity", ontapConfig.ThroughputCapacity)
d.Set("throughput_capacity_per_ha_pair", nil)
}
d.Set("vpc_id", filesystem.VpcId)
d.Set("weekly_maintenance_start_time", filesystem.OntapConfiguration.WeeklyMaintenanceStartTime)
d.Set("weekly_maintenance_start_time", ontapConfig.WeeklyMaintenanceStartTime)

tags := KeyValueTags(ctx, filesystem.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig)

Expand Down
2 changes: 2 additions & 0 deletions internal/service/fsx/ontap_file_system_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func TestAccFSxONTAPFileSystemDataSource_Id(t *testing.T) {
resource.TestCheckResourceAttrPair(datasourceName, "dns_name", resourceName, "dns_name"),
resource.TestCheckResourceAttrPair(datasourceName, "endpoint_ip_address_range", resourceName, "endpoint_ip_address_range"),
resource.TestCheckResourceAttrPair(datasourceName, "endpoints.#", resourceName, "endpoints.#"),
resource.TestCheckResourceAttrPair(datasourceName, "ha_pairs", resourceName, "ha_pairs"),
resource.TestCheckResourceAttrPair(datasourceName, "kms_key_id", resourceName, "kms_key_id"),
resource.TestCheckResourceAttrPair(datasourceName, "network_interface_ids.#", resourceName, "network_interface_ids.#"),
resource.TestCheckResourceAttrPair(datasourceName, "owner_id", resourceName, "owner_id"),
Expand All @@ -48,6 +49,7 @@ func TestAccFSxONTAPFileSystemDataSource_Id(t *testing.T) {
resource.TestCheckResourceAttrPair(datasourceName, "subnet_ids.#", resourceName, "subnet_ids.#"),
resource.TestCheckResourceAttrPair(datasourceName, "tags.%", resourceName, "tags.%"),
resource.TestCheckResourceAttrPair(datasourceName, "throughput_capacity", resourceName, "throughput_capacity"),
resource.TestCheckResourceAttrPair(datasourceName, "throughput_capacity_per_ha_pair", resourceName, "throughput_capacity_per_ha_pair"),
resource.TestCheckResourceAttrPair(datasourceName, "vpc_id", resourceName, "vpc_id"),
resource.TestCheckResourceAttrPair(datasourceName, "weekly_maintenance_start_time", resourceName, "weekly_maintenance_start_time"),
),
Expand Down
51 changes: 50 additions & 1 deletion internal/service/fsx/ontap_file_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func TestAccFSxONTAPFileSystem_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "endpoints.0.intercluster.0.dns_name"),
resource.TestCheckResourceAttr(resourceName, "endpoints.0.management.#", "1"),
resource.TestCheckResourceAttrSet(resourceName, "endpoints.0.management.0.dns_name"),
resource.TestCheckResourceAttr(resourceName, "ha_pairs", "1"),
resource.TestCheckResourceAttrSet(resourceName, "kms_key_id"),
resource.TestCheckResourceAttr(resourceName, "network_interface_ids.#", "2"),
acctest.CheckResourceAttrAccountID(resourceName, "owner_id"),
Expand All @@ -61,6 +62,7 @@ func TestAccFSxONTAPFileSystem_basic(t *testing.T) {
resource.TestCheckTypeSetElemAttrPair(resourceName, "subnet_ids.*", "aws_subnet.test.1", "id"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttr(resourceName, "throughput_capacity", "128"),
resource.TestCheckResourceAttr(resourceName, "throughput_capacity_per_ha_pair", "0"),
resource.TestCheckResourceAttrPair(resourceName, "vpc_id", "aws_vpc.test", "id"),
resource.TestMatchResourceAttr(resourceName, "weekly_maintenance_start_time", regexache.MustCompile(`^\d:\d\d:\d\d$`)),
),
Expand Down Expand Up @@ -91,7 +93,6 @@ func TestAccFSxONTAPFileSystem_singleAZ(t *testing.T) {
Config: testAccONTAPFileSystemConfig_singleAZ(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckONTAPFileSystemExists(ctx, resourceName, &filesystem),
acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "fsx", regexache.MustCompile(`file-system/fs-.+`)),
resource.TestCheckResourceAttr(resourceName, "deployment_type", fsx.OntapDeploymentTypeSingleAz1),
),
},
Expand All @@ -105,6 +106,37 @@ func TestAccFSxONTAPFileSystem_singleAZ(t *testing.T) {
})
}

func TestAccFSxONTAPFileSystem_haPair(t *testing.T) {
ctx := acctest.Context(t)
var filesystem fsx.FileSystem
resourceName := "aws_fsx_ontap_file_system.test"
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, fsx.EndpointsID) },
ErrorCheck: acctest.ErrorCheck(t, fsx.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckONTAPFileSystemDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccONTAPFileSystemConfig_haPair(rName, 3072),
Check: resource.ComposeTestCheckFunc(
testAccCheckONTAPFileSystemExists(ctx, resourceName, &filesystem),
resource.TestCheckResourceAttr(resourceName, "ha_pairs", "2"),
resource.TestCheckResourceAttr(resourceName, "throughput_capacity", "0"),
resource.TestCheckResourceAttr(resourceName, "throughput_capacity_per_ha_pair", "3072"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"security_group_ids"},
},
},
})
}

func TestAccFSxONTAPFileSystem_fsxAdminPassword(t *testing.T) {
ctx := acctest.Context(t)
var filesystem1, filesystem2 fsx.FileSystem
Expand Down Expand Up @@ -690,6 +722,23 @@ resource "aws_fsx_ontap_file_system" "test" {
`, rName))
}

func testAccONTAPFileSystemConfig_haPair(rName string, capacity int) string {
return acctest.ConfigCompose(testAccONTAPFileSystemConfig_base(rName), fmt.Sprintf(`
resource "aws_fsx_ontap_file_system" "test" {
storage_capacity = 2048
subnet_ids = [aws_subnet.test[0].id]
deployment_type = "SINGLE_AZ_2"
ha_pairs = 2
throughput_capacity_per_ha_pair = %[2]d
preferred_subnet_id = aws_subnet.test[0].id

tags = {
Name = %[1]q
}
}
`, rName, capacity))
}

func testAccONTAPFileSystemConfig_adminPassword(rName, pass string) string {
return acctest.ConfigCompose(testAccONTAPFileSystemConfig_base(rName), fmt.Sprintf(`
resource "aws_fsx_ontap_file_system" "test" {
Expand Down
4 changes: 3 additions & 1 deletion website/docs/d/fsx_ontap_file_system.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ In addition to all arguments above, the following attributes are exported:
* `dns_name` - DNS name for the file system (e.g. `fs-12345678.corp.example.com`).
* `endpoint_ip_address_range` - (Multi-AZ only) Specifies the IP address range in which the endpoints to access your file system exist.
* `endpoints` - The Management and Intercluster FileSystemEndpoints that are used to access data or to manage the file system using the NetApp ONTAP CLI, REST API, or NetApp SnapMirror. See [FileSystemEndpoints](#file-system-endpoints) below.
* `ha_pairs` - The number of HA pairs for the file system.
* `id` - Identifier of the file system (e.g. `fs-12345678`).
* `kms_key_id` - ARN for the KMS Key to encrypt the file system at rest.
* `network_interface_ids` - The IDs of the elastic network interfaces from which a specific file system is accessible.
Expand All @@ -48,7 +49,8 @@ In addition to all arguments above, the following attributes are exported:
* `storage_type` - The type of storage the file system is using. If set to `SSD`, the file system uses solid state drive storage. If set to `HDD`, the file system uses hard disk drive storage.
* `subnet_ids` - Specifies the IDs of the subnets that the file system is accessible from. For the MULTI_AZ_1 file system deployment type, there are two subnet IDs, one for the preferred file server and one for the standby file server. The preferred file server subnet identified in the `preferred_subnet_id` property.
* `tags` - The tags associated with the file system.
* `throughput_capacity` - The sustained throughput of an Amazon FSx file system in Megabytes per second (MBps).
* `throughput_capacity` - The sustained throughput of an Amazon FSx file system in Megabytes per second (MBps). If the file system uses multiple HA pairs this will equal throuthput_capacity_per_ha_pair x ha_pairs
* `throughput_capacity_per_ha_pair` - The sustained throughput of each HA pair for an Amazon FSx file system in Megabytes per second (MBps).
* `vpc_id` - The ID of the primary virtual private cloud (VPC) for the file system.
* `weekly_maintenance_start_time` - The preferred start time (in `D:HH:MM` format) to perform weekly maintenance, in the UTC time zone.

Expand Down
6 changes: 4 additions & 2 deletions website/docs/r/fsx_ontap_file_system.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ resource "aws_fsx_ontap_file_system" "test" {
This resource supports the following arguments:

* `storage_capacity` - (Optional) The storage capacity (GiB) of the file system. Valid values between `1024` and `196608`.
* `subnet_ids` - (Required) A list of IDs for the subnets that the file system will be accessible from. Upto 2 subnets can be provided.
* `subnet_ids` - (Required) A list of IDs for the subnets that the file system will be accessible from. Up to 2 subnets can be provided.
* `preferred_subnet_id` - (Required) The ID for a subnet. A subnet is a range of IP addresses in your virtual private cloud (VPC).
* `security_group_ids` - (Optional) A list of IDs for the security groups that apply to the specified network interfaces created for file system access. These security groups will apply to all network interfaces.
* `weekly_maintenance_start_time` - (Optional) The preferred start time (in `d:HH:MM` format) to perform weekly maintenance, in the UTC time zone.
Expand All @@ -38,11 +38,13 @@ This resource supports the following arguments:
* `daily_automatic_backup_start_time` - (Optional) A recurring daily time, in the format HH:MM. HH is the zero-padded hour of the day (0-23), and MM is the zero-padded minute of the hour. For example, 05:00 specifies 5 AM daily. Requires `automatic_backup_retention_days` to be set.
* `disk_iops_configuration` - (Optional) The SSD IOPS configuration for the Amazon FSx for NetApp ONTAP file system. See [Disk Iops Configuration](#disk-iops-configuration) below.
* `endpoint_ip_address_range` - (Optional) Specifies the IP address range in which the endpoints to access your file system will be created. By default, Amazon FSx selects an unused IP address range for you from the 198.19.* range.
* `ha_pairs` - (Optional) - The number of ha_pairs to deploy for the file system. Valid values are 1 through 6. Recommend only using this parameter for 2 or more ha pairs.
* `storage_type` - (Optional) - The filesystem storage type. defaults to `SSD`.
* `fsx_admin_password` - (Optional) The ONTAP administrative password for the fsxadmin user that you can use to administer your file system using the ONTAP CLI and REST API.
* `route_table_ids` - (Optional) Specifies the VPC route tables in which your file system's endpoints will be created. You should specify all VPC route tables associated with the subnets in which your clients are located. By default, Amazon FSx selects your VPC's default route table.
* `tags` - (Optional) A map of tags to assign to the file system. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.
* `throughput_capacity` - (Required) Sets the throughput capacity (in MBps) for the file system that you're creating. Valid values are `128`, `256`, `512`, `1024`, `2048`, and `4096`.
* `throughput_capacity` - (Optional) Sets the throughput capacity (in MBps) for the file system that you're creating. Valid values are `128`, `256`, `512`, `1024`, `2048`, and `4096`. This parameter should only be used when specifying not using the ha_pairs parameter. Either throughput_capacity or throughput_capacity_per_ha_pair must be specified.
* `throughput_capacity_per_ha_pair` - (Optional) Sets the throughput capacity (in MBps) for the file system that you're creating. Valid values are `3072`,`6144`. This parameter should only be used when specifying the ha_pairs parameter. Either throughput_capacity or throughput_capacity_per_ha_pair must be specified.

### Disk Iops Configuration

Expand Down