Skip to content

Instantly share code, notes, and snippets.

View rileydakota's full-sized avatar

rileydakota

  • Aquia, Inc
  • Remote
View GitHub Profile
@rileydakota
rileydakota / duckdb_cloudtrail_load.sql
Last active July 16, 2024 22:27
Load and Query AWS CloudTrail direct from DuckDB
INSTALL AWS;
LOAD AWS;
CALL load_aws_credentials();
CREATE TABLE ct_raw AS SELECT * FROM read_json('s3://YOUR_CT_BUCKET_WITH_A_DATE_PREFIX/*.gz', maximum_depth=2);
CREATE TABLE ct as SELECT unnest(Records) as Event FROM ct_raw;
CREATE TABLE cloudtrail_events AS SELECT json_extract_string(event, '$.eventVersion') AS eventVersion,
json_extract_string(event, '$.userIdentity.type') AS userType,
json_extract_string(event, '$.userIdentity.principalId') AS principalId,
json_extract_string(event, '$.userIdentity.arn') AS userArn,
json_extract_string(event, '$.userIdentity.accountId') AS accountId,
@rileydakota
rileydakota / github_oidc_role.yml
Last active July 3, 2023 22:21
CloudFormation Template for IAM Role for GitHub OIDC with latest fingerprints
Parameters:
GitHubOrg:
Type: String
RepositoryName:
Type: String
Resources:
Role:
Type: AWS::IAM::Role
Properties: