-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added queries for unused resources cost (#348)
- Loading branch information
Showing
44 changed files
with
485 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_acm_certs.sql
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 @@ | ||
{{unused_route53_histed_zones()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_backup_vaults.sql
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 @@ | ||
{{unused_backup_vaults()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_cloudfront_distributions.sql
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 @@ | ||
{{unused_cloudfront_distributions()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_directconntect_connections.sql
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 @@ | ||
{{unused_directconntect_connections()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_dynamodb_tables.sql
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 @@ | ||
{{unused_dynamodb_tables()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_ec2_ebs_volumes.sql
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 @@ | ||
{{unused_ec2_ebs_volumes()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_ec2_eips.sql
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 @@ | ||
{{unused_ec2_eips()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_ec2_hosts.sql
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 @@ | ||
{{unused_ec2_hosts()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_ec2_images.sql
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 @@ | ||
{{unused_ec2_images()}} |
3 changes: 3 additions & 0 deletions
3
transformations/aws/cost/models/unused/aws_cost__unused_ec2_internet_gateways.sql
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,3 @@ | ||
-- depends_on: {{ ref('aws_cost__by_resources') }} | ||
|
||
{{unused_ec2_internet_gateways()}} |
3 changes: 3 additions & 0 deletions
3
transformations/aws/cost/models/unused/aws_cost__unused_ec2_network_acls.sql
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,3 @@ | ||
-- depends_on: {{ ref('aws_cost__by_resources') }} | ||
|
||
{{unused_ec2_network_acls()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_ec2_transit_gateways.sql
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 @@ | ||
{{unused_ec2_transit_gateways()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_ecr_repositories.sql
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 @@ | ||
{{unused_ecr_repositories()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_efs_filesystems.sql
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 @@ | ||
{{unused_efs_filesystems()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_lightsail_container_services.sql
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 @@ | ||
{{unused_lightsail_container_services()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_lightsail_disks.sql
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 @@ | ||
{{unused_lightsail_disks()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_lightsail_distributions.sql
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 @@ | ||
{{unused_lightsail_distributions()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_lightsail_load_balancers.sql
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 @@ | ||
{{unused_lightsail_load_balancers()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_lightsail_static_ips.sql
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 @@ | ||
{{unused_lightsail_static_ips()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_load_balancers.sql
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 @@ | ||
{{unused_load_balancers()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_route53_histed_zones.sql
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 @@ | ||
{{unused_route53_histed_zones()}} |
1 change: 1 addition & 0 deletions
1
transformations/aws/cost/models/unused/aws_cost__unused_sns_topics.sql
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 @@ | ||
{{unused_sns_topics()}} |
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,18 @@ | ||
{% macro unused_acm_certs(framework, check_id) %} | ||
{{ return(adapter.dispatch('unused_acm_certs')(framework, check_id)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__unused_acm_certs(framework, check_id) %}{% endmacro %} | ||
|
||
{% macro postgres__unused_acm_certs(framework, check_id) %} | ||
select | ||
c.account_id, | ||
c.arn as resource_id, | ||
rbc.cost | ||
from aws_acm_certificates c | ||
JOIN {{ ref('aws_cost__by_resources') }} rbc ON c.arn = rbc.line_item_resource_id | ||
where array_length(c.in_use_by, 1) = 0 | ||
{% endmacro %} | ||
|
||
{% macro snowflake__unused_acm_certs(framework, check_id) %} | ||
{% endmacro %} |
29 changes: 29 additions & 0 deletions
29
transformations/aws/macros/unused/unused_backup_vaults.sql
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 @@ | ||
{% macro unused_backup_vaults(framework, check_id) %} | ||
{{ return(adapter.dispatch('unused_backup_vaults')(framework, check_id)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__unused_backup_vaults(framework, check_id) %}{% endmacro %} | ||
|
||
{% macro postgres__unused_backup_vaults(framework, check_id) %} | ||
with point as ( | ||
select distinct vault_arn | ||
from aws_backup_vault_recovery_points | ||
), | ||
unused_vaults as ( | ||
select | ||
vault.account_id, | ||
vault.arn as resource_id | ||
from aws_backup_vaults vault | ||
left join point on point.vault_arn = vault.arn | ||
where point.vault_arn is null) | ||
SELECT | ||
uv.account_id, | ||
uv.resource_id, | ||
rbc.cost | ||
FROM unused_vaults uv | ||
JOIN {{ ref('aws_cost__by_resources') }} rbc ON uv.resource_id = rbc.line_item_resource_id | ||
{% endmacro %} | ||
|
||
{% macro snowflake__unused_backup_vaults(framework, check_id) %} | ||
|
||
{% endmacro %} |
19 changes: 19 additions & 0 deletions
19
transformations/aws/macros/unused/unused_cloudfront_distributions.sql
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,19 @@ | ||
{% macro unused_cloudfront_distributions(framework, check_id) %} | ||
{{ return(adapter.dispatch('unused_cloudfront_distributions')(framework, check_id)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__unused_cloudfront_distributions(framework, check_id) %}{% endmacro %} | ||
|
||
{% macro postgres__unused_cloudfront_distributions(framework, check_id) %} | ||
select | ||
d.account_id, | ||
d.arn as resource_id, | ||
rbc.cost | ||
from aws_cloudfront_distributions d | ||
JOIN {{ ref('aws_cost__by_resources') }} rbc ON d.arn = rbc.line_item_resource_id | ||
where (d.distribution_config->>'Enabled')::boolean is distinct from true | ||
{% endmacro %} | ||
|
||
{% macro snowflake__unused_cloudfront_distributions(framework, check_id) %} | ||
|
||
{% endmacro %} |
19 changes: 19 additions & 0 deletions
19
transformations/aws/macros/unused/unused_directconntect_connections.sql
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,19 @@ | ||
{% macro unused_directconntect_connections(framework, check_id) %} | ||
{{ return(adapter.dispatch('unused_directconntect_connections')(framework, check_id)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__unused_directconntect_connections(framework, check_id) %}{% endmacro %} | ||
|
||
{% macro postgres__unused_directconntect_connections(framework, check_id) %} | ||
select | ||
dc.account_id, | ||
dc.arn as resource_id, | ||
rbc.cost | ||
from aws_directconnect_connections dc | ||
JOIN {{ ref('aws_cost__by_resources') }} rbc ON dc.arn = rbc.line_item_resource_id | ||
where dc.connection_state = 'down' | ||
{% endmacro %} | ||
|
||
{% macro snowflake__unused_directconntect_connections(framework, check_id) %} | ||
|
||
{% endmacro %} |
19 changes: 19 additions & 0 deletions
19
transformations/aws/macros/unused/unused_dynamodb_tables.sql
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,19 @@ | ||
{% macro unused_dynamodb_tables(framework, check_id) %} | ||
{{ return(adapter.dispatch('unused_dynamodb_tables')(framework, check_id)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__unused_dynamodb_tables(framework, check_id) %}{% endmacro %} | ||
|
||
{% macro postgres__unused_dynamodb_tables(framework, check_id) %} | ||
select | ||
ddb.account_id, | ||
ddb.arn as resource_id, | ||
rbc.cost | ||
from aws_dynamodb_tables ddb | ||
JOIN {{ ref('aws_cost__by_resources') }} rbc ON ddb.arn = rbc.line_item_resource_id | ||
where ddb.item_count = 0 | ||
{% endmacro %} | ||
|
||
{% macro snowflake__unused_dynamodb_tables(framework, check_id) %} | ||
|
||
{% endmacro %} |
19 changes: 19 additions & 0 deletions
19
transformations/aws/macros/unused/unused_ec2_ebs_volumes.sql
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,19 @@ | ||
{% macro unused_ec2_ebs_volumes(framework, check_id) %} | ||
{{ return(adapter.dispatch('unused_ec2_ebs_volumes')(framework, check_id)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__unused_ec2_ebs_volumes(framework, check_id) %}{% endmacro %} | ||
|
||
{% macro postgres__unused_ec2_ebs_volumes(framework, check_id) %} | ||
select | ||
ev.account_id, | ||
ev.arn as resource_id, | ||
rbc.cost | ||
from aws_ec2_ebs_volumes ev | ||
JOIN {{ ref('aws_cost__by_resources') }} rbc ON ev.arn = rbc.line_item_resource_id | ||
where coalesce(jsonb_array_length(ev.attachments), 0) = 0 | ||
{% endmacro %} | ||
|
||
{% macro snowflake__unused_ec2_ebs_volumes(framework, check_id) %} | ||
|
||
{% endmacro %} |
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,19 @@ | ||
{% macro unused_ec2_eips(framework, check_id) %} | ||
{{ return(adapter.dispatch('unused_ec2_eips')(framework, check_id)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__unused_ec2_eips(framework, check_id) %}{% endmacro %} | ||
|
||
{% macro postgres__unused_ec2_eips(framework, check_id) %} | ||
select | ||
eips.account_id, | ||
eips.allocation_id as resource_id, | ||
rbc.cost | ||
from aws_ec2_eips eips | ||
JOIN {{ ref('aws_cost__by_resources') }} rbc ON eips.allocation_id = rbc.line_item_resource_id | ||
where eips.association_id is null | ||
{% endmacro %} | ||
|
||
{% macro snowflake__unused_ec2_eips(framework, check_id) %} | ||
|
||
{% endmacro %} |
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,19 @@ | ||
{% macro unused_ec2_hosts(framework, check_id) %} | ||
{{ return(adapter.dispatch('unused_ec2_hosts')(framework, check_id)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__unused_ec2_hosts(framework, check_id) %}{% endmacro %} | ||
|
||
{% macro postgres__unused_ec2_hosts(framework, check_id) %} | ||
select | ||
h.account_id, | ||
h.arn as resource_id, | ||
rbc.cost | ||
from aws_ec2_hosts h | ||
JOIN {{ ref('aws_cost__by_resources') }} rbc ON h.arn = rbc.line_item_resource_id | ||
where coalesce(jsonb_array_length(h.instances), 0) = 0 | ||
{% endmacro %} | ||
|
||
{% macro snowflake__unused_ec2_hosts(framework, check_id) %} | ||
|
||
{% endmacro %} |
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,19 @@ | ||
{% macro unused_ec2_images(framework, check_id) %} | ||
{{ return(adapter.dispatch('unused_ec2_images')(framework, check_id)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__unused_ec2_images(framework, check_id) %}{% endmacro %} | ||
|
||
{% macro postgres__unused_ec2_images(framework, check_id) %} | ||
select | ||
i.account_id, | ||
i.arn as resource_id, | ||
rbc.cost | ||
from aws_ec2_images i | ||
JOIN {{ ref('aws_cost__by_resources') }} rbc ON i.arn = rbc.line_item_resource_id | ||
where coalesce(jsonb_array_length(i.block_device_mappings), 0) = 0 | ||
{% endmacro %} | ||
|
||
{% macro snowflake__unused_ec2_images(framework, check_id) %} | ||
|
||
{% endmacro %} |
19 changes: 19 additions & 0 deletions
19
transformations/aws/macros/unused/unused_ec2_internet_gateways.sql
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,19 @@ | ||
{% macro unused_ec2_internet_gateways(framework, check_id) %} | ||
{{ return(adapter.dispatch('unused_ec2_internet_gateways')(framework, check_id)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__unused_ec2_internet_gateways(framework, check_id) %}{% endmacro %} | ||
|
||
{% macro postgres__unused_ec2_internet_gateways(framework, check_id) %} | ||
select | ||
ig.account_id, | ||
ig.arn as resource_id, | ||
rbc.cost | ||
from aws_ec2_internet_gateways ig | ||
JOIN {{ ref('aws_cost__by_resources') }} rbc ON ig.arn = rbc.line_item_resource_id | ||
where coalesce(jsonb_array_length(ig.attachments), 0) = 0 | ||
{% endmacro %} | ||
|
||
{% macro snowflake__unused_ec2_internet_gateways(framework, check_id) %} | ||
|
||
{% endmacro %} |
18 changes: 18 additions & 0 deletions
18
transformations/aws/macros/unused/unused_ec2_network_acls.sql
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,18 @@ | ||
{% macro unused_ec2_network_acls(framework, check_id) %} | ||
{{ return(adapter.dispatch('unused_ec2_network_acls')(framework, check_id)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__unused_ec2_network_acls(framework, check_id) %}{% endmacro %} | ||
|
||
{% macro postgres__unused_ec2_network_acls(framework, check_id) %} | ||
select | ||
a.account_id, | ||
a.arn as resource_id, | ||
rbc.cost | ||
from aws_ec2_network_acls a | ||
JOIN {{ ref('aws_cost__by_resources') }} rbc ON a.arn = rbc.line_item_resource_id | ||
where coalesce(jsonb_array_length(a.associations), 0) = 0 | ||
{% endmacro %} | ||
|
||
{% macro snowflake__unused_ec2_network_acls(framework, check_id) %} | ||
{% endmacro %} |
26 changes: 26 additions & 0 deletions
26
transformations/aws/macros/unused/unused_ec2_transit_gateways.sql
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,26 @@ | ||
{% macro unused_ec2_transit_gateways(framework, check_id) %} | ||
{{ return(adapter.dispatch('unused_ec2_transit_gateways')(framework, check_id)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__unused_ec2_transit_gateways(framework, check_id) %}{% endmacro %} | ||
|
||
{% macro postgres__unused_ec2_transit_gateways(framework, check_id) %} | ||
with attachment as (select distinct transit_gateway_arn from aws_ec2_transit_gateway_attachments), | ||
unused_transit_gateways as ( | ||
select | ||
gateway.account_id, | ||
gateway.arn as resource_id | ||
from aws_ec2_transit_gateways gateway | ||
left join attachment on attachment.transit_gateway_arn = gateway.arn | ||
where attachment.transit_gateway_arn is null) | ||
SELECT | ||
ug.account_id, | ||
ug.resource_id, | ||
rbc.cost | ||
FROM unused_transit_gateways ug | ||
JOIN {{ ref('aws_cost__by_resources') }} rbc ON ug.resource_id = rbc.line_item_resource_id | ||
{% endmacro %} | ||
|
||
{% macro snowflake__unused_ec2_transit_gateways(framework, check_id) %} | ||
|
||
{% endmacro %} |
26 changes: 26 additions & 0 deletions
26
transformations/aws/macros/unused/unused_ecr_repositories.sql
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,26 @@ | ||
{% macro unused_ecr_repositories(framework, check_id) %} | ||
{{ return(adapter.dispatch('unused_ecr_repositories')(framework, check_id)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__unused_ecr_repositories(framework, check_id) %}{% endmacro %} | ||
|
||
{% macro postgres__unused_ecr_repositories(framework, check_id) %} | ||
with image as (select distinct account_id, repository_name from aws_ecr_repository_images), | ||
unused_repo as ( | ||
select | ||
repository.account_id, | ||
repository.arn as resource_id | ||
from aws_ecr_repositories repository | ||
left join image on image.account_id = repository.account_id and image.repository_name = repository.repository_name | ||
where image.repository_name is null) | ||
SELECT | ||
ur.account_id, | ||
ur.resource_id, | ||
rbc.cost | ||
FROM unused_repo ur | ||
JOIN {{ ref('aws_cost__by_resources') }} rbc ON ur.resource_id = rbc.line_item_resource_id | ||
{% endmacro %} | ||
|
||
{% macro snowflake__unused_ecr_repositories(framework, check_id) %} | ||
|
||
{% endmacro %} |
19 changes: 19 additions & 0 deletions
19
transformations/aws/macros/unused/unused_efs_filesystems.sql
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,19 @@ | ||
{% macro unused_efs_filesystems(framework, check_id) %} | ||
{{ return(adapter.dispatch('unused_efs_filesystems')(framework, check_id)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__unused_efs_filesystems(framework, check_id) %}{% endmacro %} | ||
|
||
{% macro postgres__unused_efs_filesystems(framework, check_id) %} | ||
select | ||
fs.account_id, | ||
fs.arn as resource_id, | ||
rbc.cost | ||
from aws_efs_filesystems fs | ||
JOIN {{ ref('aws_cost__by_resources') }} rbc ON fs.arn = rbc.line_item_resource_id | ||
where fs.number_of_mount_targets = 0 | ||
{% endmacro %} | ||
|
||
{% macro snowflake__unused_efs_filesystems(framework, check_id) %} | ||
|
||
{% endmacro %} |
26 changes: 26 additions & 0 deletions
26
transformations/aws/macros/unused/unused_lightsail_container_services.sql
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,26 @@ | ||
{% macro unused_lightsail_container_services(framework, check_id) %} | ||
{{ return(adapter.dispatch('unused_lightsail_container_services')(framework, check_id)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__unused_lightsail_container_services(framework, check_id) %}{% endmacro %} | ||
|
||
{% macro postgres__unused_lightsail_container_services(framework, check_id) %} | ||
with deployment as (select distinct container_service_arn from aws_lightsail_container_service_deployments), | ||
unused_cs AS ( | ||
select | ||
cs.account_id, | ||
cs.arn as resource_id | ||
from aws_lightsail_container_services cs | ||
left join deployment on deployment.container_service_arn = cs.arn | ||
where deployment.container_service_arn is null) | ||
SELECT | ||
cs.account_id, | ||
cs.resource_id, | ||
rbc.cost | ||
FROM unused_cs cs | ||
JOIN {{ ref('aws_cost__by_resources') }} rbc ON cs.resource_id = rbc.line_item_resource_id | ||
{% endmacro %} | ||
|
||
{% macro snowflake__unused_lightsail_container_services(framework, check_id) %} | ||
|
||
{% endmacro %} |
Oops, something went wrong.