Aws prefix list data element + name with spaces

Hello! I’m wondering if I could get some pointers on how to use an aws_prefix_list data element to reference a prefix list that has spaces in its name? Both

data "aws_prefix_list" "blah" {*
  filter {
    name   = "prefix-list-name"
    values = ["My Name Here"]
  }
}

and

data "aws_prefix_list" "blah" {
  name = "My Name Here"
}

throw errors complaining about invalid characters:
│ Error: InvalidFilter: The filter value My Name Here contains unsupported characters
│ status code: 400, request id: fdb89dfa-8130-4552-b163-b274f96f83ef

yet I’m able to execute the comparable filter via the AWS CLI just fine, for example
aws ec2 describe-managed-prefix-lists --filters "Name=prefix-list-name,Values=My Name Here"

Do I need to do something to escape the spaces?

This just tripped me up too. It turns out aws_prefix_list is used when querying the AWS managed lists. For the user managed lists you need to use aws_ec2_managed_prefix_list

1 Like