From f27f70f02df4274c99e5f0aada1b0b7ed5fbabca Mon Sep 17 00:00:00 2001 From: Chris Stephens Date: Tue, 19 Mar 2019 16:38:27 -0700 Subject: [PATCH] Sort import regex's --- provider/terraform/import.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/provider/terraform/import.rb b/provider/terraform/import.rb index 58e24840a6fa..be9a90bc40ab 100644 --- a/provider/terraform/import.rb +++ b/provider/terraform/import.rb @@ -52,7 +52,9 @@ def import_id_formats(resource) field_markers -= ['{{project}}', '{{region}}', '{{zone}}'] short_id_default_format = field_markers.join('/') - (id_formats + [short_id_format, short_id_default_format]).uniq.reject(&:empty?) + # Regexes should be unique and ordered from most specific to least specific + (id_formats + [short_id_format, short_id_default_format]). + uniq.reject(&:empty?).sort_by{|i| i.count('/')}.reverse end end end