Skip to content

Commit

Permalink
Merge branch 'main' into renovate/cloudquery-monorepo-modules
Browse files Browse the repository at this point in the history
  • Loading branch information
k-rheinheimer authored Aug 29, 2024
2 parents 8918a45 + c2754f7 commit 010d194
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ SPLIT_PART(arn, ':', 3) AS service,
FROM {{ table_name | string }}
{% endmacro %}

{% macro bigquery__aws_asset_resources(table_name, ARN_EXIST, ACCOUNT_ID_EXIST, REQUEST_ACCOUNT_ID_EXIST, REGION_EXIST, TAGS_EXIST) -%}
SELECT
_cq_id, _cq_source_name, _cq_sync_time,{% if ACCOUNT_ID_EXIST %} account_id {% else %} SPLIT(arn, ':')[5] {% endif %} AS account_id, {% if REQUEST_ACCOUNT_ID_EXIST %} request_account_id {% else %} SPLIT(arn, ':')[5] {% endif %} AS request_account_id, CASE WHEN SPLIT(SPLIT(arn, ':')[6], '/')[2] = '' AND SPLIT(arn, ':')[7] = '' THEN NULL ELSE SPLIT(SPLIT(arn, ':')[6], '/')[1] END AS TYPE, arn, {% if REGION_EXIST %} region {% else %} 'unavailable' {% endif %} AS region, {% if TAGS_EXIST %} TO_JSON_STRING(tags) {% else %} TO_JSON_STRING(STRUCT()) {% endif %} AS tags, SPLIT(arn, ':')[2] AS PARTITIONS, SPLIT(arn, ':')[3] AS service, '{{ table_name | string }}' AS _cq_table
{%- macro bigquery__aws_asset_resources(table_name, ARN_EXIST, ACCOUNT_ID_EXIST, REQUEST_ACCOUNT_ID_EXIST, REGION_EXIST, TAGS_EXIST) -%}
SELECT
_cq_id, _cq_source_name, _cq_sync_time,{% if ACCOUNT_ID_EXIST %} account_id {% else %} SPLIT(arn, ':')[5] {% endif %} AS account_id, {% if REQUEST_ACCOUNT_ID_EXIST %} request_account_id {% else %} SPLIT(arn, ':')[5] {% endif %} AS request_account_id, CASE WHEN SPLIT(SPLIT(arn, ':')[6], '/')[2] = '' AND SPLIT(arn, ':')[7] = '' THEN NULL ELSE SPLIT(SPLIT(arn, ':')[6], '/')[1] END AS TYPE, arn, {% if REGION_EXIST %} region {% else %} 'unavailable' {% endif %} AS region, {% if TAGS_EXIST %} TO_JSON_STRING(tags) {% else %} TO_JSON_STRING(STRUCT()) {% endif %} AS tags, SPLIT(arn, ':')[2] AS PARTITIONS, SPLIT(arn, ':')[3] AS service, '{{ table_name | string }}' AS _cq_table
FROM {{ full_table_name(table_name | string) }}
{% endmacro %}
{%- endmacro -%}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
{{ aws_tables_dyn() }}
{% endset %}

-- Generate dynamic SQL statements
{% for row in run_query(aws_tables) -%}
{% if row.table_name is not none and row.table_name != '' -%}
{%- for row in run_query(aws_tables) -%}
{%- if row.table_name is not none and row.table_name != '' -%}
{{ aws_asset_resources(row.table_name, row.arn_exist, row.account_id_exist, row.request_account_id_exist, row.region_exist, row.tags_exist) }}
{% if not loop.last -%} UNION ALL {% endif -%}
{%- endif %}
{%- endfor %}
{%- if not loop.last -%} UNION ALL {% endif -%}
{%- endif -%}
{%- endfor -%}
7 changes: 4 additions & 3 deletions transformations/aws/asset-inventory-free/tests/bigquery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ kind: source
spec:
name: aws
path: cloudquery/aws
registry: cloudquery
version: "v27.16.0" # latest version of source aws plugin
registry: cloudquery\
version: "v27.17.0" # latest version of source aws plugin
destinations: ["bigquery"]
tables: ["*"]
skip_dependent_tables: true
---
kind: destination
spec:
name: bigquery
path: cloudquery/bigquery
registry: cloudquery
version: "v3.3.9"
version: "v4.1.7"
write_mode: "append"
spec:
project_id: cq-integration-tests
Expand Down

0 comments on commit 010d194

Please sign in to comment.