Search code examples
sqlamazon-ec2aws-config

AWS config query with wildcard in resourceType


I'm trying to get all associated resource relationship types for a specific EC2. Is it possible to use a wildcard in an AWS config query in the WHERE block with resourceType rather than having to declare each type?

What I am doing that's working:

SELECT
  *
WHERE
  resourceType IN (
    'AWS::EC2::InternetGateway',
    'AWS::EC2::NetworkACL',
    ...

  )
  AND relationships.resourceId = 'foo'

What I want to do, but it returns empty:

SELECT
  *
WHERE
  resourceType IN (
    'AWS::EC2::*'
  )
  AND relationships.resourceId = 'foo'

Have also tried but returns empty:

SELECT
  *
WHERE
  resourceType = 'AWS::EC2::*'
  AND relationships.resourceId = 'foo'

Solution

  • The wildcard to use is '%'.

    So your example will look like this:

    SELECT
      *
    WHERE
      resourceType LIKE 'AWS::EC2::%'
      AND relationships.resourceId = 'foo'