-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional thrifty control to check unused NAT gateways. Closes #38
- Loading branch information
1 parent
9c23122
commit feac3a8
Showing
2 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
with instance_data as ( | ||
select | ||
instance_id, | ||
subnet_id, | ||
instance_state | ||
from | ||
aws_ec2_instance | ||
) | ||
select | ||
-- Required Columns | ||
nat.arn as resource, | ||
case | ||
when nat.state <> 'available' then 'alarm' | ||
when i.subnet_id is null then 'alarm' | ||
when i.instance_state <> 'running' then 'alarm' | ||
else 'ok' | ||
end as status, | ||
case | ||
when nat.state <> 'available' then nat.title || ' in ' || nat.state || ' state.' | ||
when i.subnet_id is null then nat.title || ' not in-use.' | ||
when i.instance_state <> 'running' then nat.title || ' associated with ' || i.instance_id || ', which is in ' || i.instance_state || ' state.' | ||
else nat.title || ' in-use.' | ||
end as reason, | ||
-- Additional Dimensions | ||
nat.region, | ||
nat.account_id | ||
from | ||
aws_vpc_nat_gateway as nat | ||
left join instance_data as i on nat.subnet_id = i.subnet_id; |