Skip to content

Instantly share code, notes, and snippets.

@judell
Last active September 15, 2021 21:59
Show Gist options
  • Save judell/c3567d6d0e23e0e8e61a72ea4edaca2e to your computer and use it in GitHub Desktop.
Save judell/c3567d6d0e23e0e8e61a72ea4edaca2e to your computer and use it in GitHub Desktop.
PATTERN: UNION similar things to combine them
select title, id, resource from
(
select
title,
key_pair_id as id,
'aws_ec2_key_pair' as resource,
tags
from
aws_ec2_key_pair
union
select
title,
instance_id as id,
'aws_ec2_instance' as resource,
tags
from
aws_ec2_instance
) as untagged
where
untagged.tags ->> 'owner' is null
or untagged.tags ->> 'projectid' is null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment