hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.76k stars 9.12k forks source link

[Bug]: aws_fsx_lustre_file_system 'subnet_ids' is a confusing variable #39467

Open MDBeudekerCN opened 3 days ago

MDBeudekerCN commented 3 days ago

Terraform Core Version

1.8.1

AWS Provider Version

5.51.1

Affected Resource(s)

aws_fsx_lustre_file_system has a variable named 'Subnet_ids' which should be a list of string. However when inputting the subnet IDs of my VPC module private IPs as follows:

│   69:   subnet_ids       = data.terraform_remote_state.infra.outputs.vpc.private_subnets
│ 
│ Attribute subnet_ids supports 1 item maximum, but config has 3 declared.

I get the following error:

Attribute subnet_ids supports 1 item maximum, but config has 3 declared.

The variable subnet_ids should be string instead of list(string) if it supports just 1 value. Making it a string with length 1 is confusing, since AWS also only supports 1 subnet

Expected Behavior

Expected: Variable name implies you being able to specify multiple subnet IDs, but reality should be that the variable subnet_id should be singular

Actual Behavior

Attribute subnet_ids supports 1 item maximum, but config has 3 declared.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

module "vpc" {
  #checkov:skip=CKV_TF_1: "Ensure Terraform module sources use a commit hash"
  source             = "terraform-aws-modules/vpc/aws"
  version            = "5.8.1"
}

output "vpc" {
  value = module.vpc
}

resource "aws_fsx_lustre_file_system" "example" {
  import_path      = "s3:123456"
  storage_capacity = 1200
  subnet_ids       = outputs.vpc.private_subnets
}

Steps to Reproduce

See above code and try to add more subnet ID's to the variable subnet_ids

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 3 days ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

stefanfreitag commented 3 days ago

Hi @MDBeudekerCN ,

I understand your point as if only one subnet identifier is supported then the type should be string instead of list of strings. On my end I looked into the CloudFormation documentation to understand where the list of strings is coming from:

When it comes to the AWS::FSx::FileSystem the CF looks like below

{
  "Type" : "AWS::FSx::FileSystem",
  "Properties" : {
      "BackupId" : String,
      "FileSystemType" : String,
      "FileSystemTypeVersion" : String,
      "KmsKeyId" : String,
      "LustreConfiguration" : LustreConfiguration,
      "OntapConfiguration" : OntapConfiguration,
      "OpenZFSConfiguration" : OpenZFSConfiguration,
      "SecurityGroupIds" : [ String, ... ],
      "StorageCapacity" : Integer,
      "StorageType" : String,
      "SubnetIds" : [ String, ... ],
      "Tags" : [ Tag, ... ],
      "WindowsConfiguration" : WindowsConfiguration
    }
}

so the template supports different filesystems (ontap, openzfs, lustre). All of them have in common that subnet identifiers are needed, only the number of identifiers is different:

For Windows and ONTAP MULTI_AZ_1 deployment types,provide exactly two subnet IDs, one for the preferred file server and one for the standby file server. You specify one of these subnets as the preferred subnet using the WindowsConfiguration > PreferredSubnetID or OntapConfiguration > PreferredSubnetID properties. For more information about Multi-AZ file system configuration, see Availability and durability: Single-AZ and Multi-AZ file systems in the Amazon FSx for Windows User Guide and Availability and durability in the Amazon FSx for ONTAP User Guide.

For Windows SINGLE_AZ_1 and SINGLE_AZ_2 and all Lustre deployment types, provide exactly one subnet ID. The file server is launched in that subnet's Availability Zone.

(quoted from the provided link)

In the Go SDK v2 you find also SubnetIds []string when it comes to CreateFileSystemInput.

I hope the explanation helps a bit to understand the origin of the list for the subnet identifiers.