Search code examples
javaregexamazon-ec2jcloudsbrooklyn

How do I give imageNameRegex an actual regular expression


I'm trying to use a specific AMI on AWS using it's name.

It works if I set imageNameRegex = region/image_name but fails if I try any of the following:

imageNameRegex = image_name
imageNameRegex = .*/image_name
imageNameRegex = .*image_name
imageNameRegex = /.*image_name/

The aim here is that I can copy an AMI across a number of regions and have Brooklyn pick up the correct one without my having to specify a specific image id for that region.

Looking at the Brooklyn tests then I shouldn't even need a regex - as long as the name is a substring of the full name it should work.

I'm setting this in the brooklyn.properties not the yaml all though I can't imagine that makes any difference.


Solution

  • You may also need to specify the image owner.

    As I recall, jclouds does something a little surprising with image owners: if you specify an image name regex, it will only look in a small number of image owner (rather than across all 20,000+ images, which can take 60+ seconds to retrieve from AWS on some home networks).

    If you specify the image owner, then it should find it, such as:

    imageOwner = 411009282317
    

    You can also set the anyOwner location configuration, but this will check every AMI it can find:

    anyOwner = true