Search code examples
terraformterraform-provider-awsaws-storage-gateway

Terraform: aws_storagegateway_cached_iscsi_volume.volume_size_in_bytes cannot create drives more than 1GB


I am creating an AWS Volume Storage Gateway. I can create the Gateway, Cache and Upload Buffer. However, I cannot create a volume larger than 1GB. It looks like an overflow problem.

  1. volume_size_in_bytes = 1 * 1024 * 1024 * 1024 creates a 1GB drive (I need 1024 GB)
  2. volume_size_in_bytes = 9 * 1024 * 1024 * 1024 fails and returns: Attribute must be a whole number, got 9.663676416e+09
  3. volume_size_in_bytes = 1099511627776 (1TiB->Bytes) returns: Attribute must be a whole number, got 1.099511627776e+12
  4. volume_size_in_bytes = 1 * 1000 * 1000 * 1000 error creating Storage Gateway cached iSCSI volume: InvalidGatewayRequestException: The specified volume is not gigabyte-aligned.

.

resource "aws_storagegateway_gateway" "apm" {
  gateway_ip_address = data.aws_instance.storagegateway.private_ip # "172.29.29.207" --need to define VM
  gateway_name       = "Pracice Management Volume Gateway"
  gateway_timezone   = "GMT"
  gateway_type       = "CACHED"  
  gateway_vpc_endpoint = data.aws_vpc_endpoint.storagegateway.dns_entry[0].dns_name
  cloudwatch_log_group_arn = data.aws_cloudwatch_log_group.storagegateway.arn  
} 

data "aws_storagegateway_local_disk" "cache" {
  disk_node   = "/dev/xvdc"
  gateway_arn = aws_storagegateway_gateway.apm.arn
}
resource "aws_storagegateway_cache" "apm" {
  disk_id     = data.aws_storagegateway_local_disk.cache.disk_id
  gateway_arn = aws_storagegateway_gateway.apm.arn
}


data "aws_storagegateway_local_disk" "buffer" {
  disk_node   = "/dev/xvdb"
  gateway_arn = aws_storagegateway_gateway.apm.arn
}
resource "aws_storagegateway_upload_buffer" "apm" {
  disk_id     = data.aws_storagegateway_local_disk.buffer.disk_id
  gateway_arn = aws_storagegateway_gateway.apm.arn
}

variable "Gb512" {
  type    = string
  default = 9 * 1024 * 1024 * 1024
}
resource "aws_storagegateway_cached_iscsi_volume" "volume01" {
  gateway_arn          =aws_storagegateway_cache.apm.gateway_arn
  network_interface_id = data.aws_instance.storagegateway.private_ip
  target_name          = "volume01"
  volume_size_in_bytes = var.Gb512
  
}

I have tried defining Gb512 as number and string. I tried string, because the errors look like numeric overflow errors.


Solution

  • Terraform from the 386 (32 bit) release cannot handle the number. I had to change Terraform.exe to use the AMD64 version. Downloads at: https://www.terraform.io/downloads

    I Defined var GB as 1024 * 1024 * 1024. I set:

    variable "GB" {
      type    = number
      default = 1024 * 1024 * 1024
    }
    ...
    volume_size_in_bytes = 500 * var.GB