Files
floci/.github/workflows/iam-data-drift.yml
T
Priamo Germosen 335b66dd27 fix(iam): read a DMS resource's tags under the key its type names (#10255)
The Service Reference lists a tag key named after each DMS resource
type, dms:rep-tag/${TagKey} on a replication instance and
dms:endpoint-tag/${TagKey} on an endpoint, which Floci never filled, so
a condition on one never matched. The DMS User Guide says "The tag keys
are prefixed with "dms", the resource type, and the "tag" prefix", in
the format dms:{resource type}-tag/{tag key}, and that such a key
"matches a resource with the given tag".

A fetcher vendors that section of the guide. The request-resources
generator reads a key of the format the reference lists on a type as
that type's stored-tag prefix, leaving out dms:req-tag/, the request's
tags, and refusing a key listed on two types. It writes the format as
tagKeyFormats, which the reader checks those keys against.

The request-resources check now also runs when one of the vendored
sources its generator reads changes, several of which were missing from
the Makefile's paths and the drift workflow's triggers.
2026-12-05 15:44:49 -04:00

262 lines
14 KiB
YAML

name: IAM Data Drift
# Checks the eleven vendored files that come from AWS's live service reference rather than from a
# pinned dependency: the IAM service namespace list, the map of which resource each IAM action is
# authorized against, the map of operations AWS authorizes as an action of another name, the
# table of the operations that pass a role and the services they pass it to, the table of the
# operations that pass a Lambda network connector, the table of the
# tagging actions operations that tag what they create need, the table of the resources each
# operation's request names, the DynamoDB condition key table, the IAM condition key table, the
# S3 Control tag condition key table, and the request condition key table (Lambda Web and Redshift). It
# also checks the routes rest-routes.json takes from the AWS page that documents an endpoint botocore does
# not model (Glue's Iceberg REST endpoint) and the legacy routes it takes from the botocore release whose
# model still gave them (SES v2's list GETs). That
# needs the live service reference index, so unlike every other check here it can
# fail without anything in the repository having changed: an AWS outage, or a namespace AWS has
# retired. It therefore runs on its own, never as part of a job that ordinary changes trigger.
#
# Two triggers, for two different failures:
#
# - On a pull request that touches a vendored file or its generator, which is where a
# hand-typed or mistyped entry would enter the repository. It checks only the files it touches,
# each with its generator and the modules that generator imports (the paths in the Makefile,
# above iam-data-verify): drift in a file it leaves alone is not its doing, and the weekly run
# reports it. Changes to Makefile, this workflow or the selector tests also trigger the job
# so the selector regression tests run. Those changes alone select no live-data checks and
# cannot be failed by an upstream data outage.
# - Weekly, because the files also go stale without anyone touching them: AWS ships services
# and actions, and occasionally retires them. Tying the only upstream check to pull request
# activity would mean a quiet month is a month with no drift detection at all.
#
# An entry AWS has *added* since the last sync is reported without failing: a new namespace makes
# the service-last-accessed report incomplete rather than wrong, and a new action or resource type
# leaves that action evaluated against `*`, which is where it was before any of this existed. The
# two condition key tables fail on an added pair as well: a key missing from the context stops a
# conditioned Allow matching and a conditioned Deny applying. The fix for a real failure is to run the matching sync target and commit the result.
#
# The offline shape check is hermetic and runs per pull request inside the "Vendored AWS data in
# sync" job in partition-literals.yml instead.
on:
pull_request:
paths:
- 'Makefile'
- 'src/main/resources/aws/iam-service-namespaces.json'
- 'src/main/resources/aws/iam-action-resources.json'
- 'tools/aws/regen_service_namespaces.py'
- 'tools/aws/test_regen_service_namespaces.py'
- 'tools/aws/regen_iam_action_resources.py'
- 'tools/aws/test_regen_iam_action_resources.py'
- 'src/main/resources/aws/iam-authorized-actions.json'
- 'tools/aws/regen_iam_authorized_actions.py'
- 'tools/aws/test_regen_iam_authorized_actions.py'
- 'src/main/resources/aws/iam-passed-roles.json'
- 'tools/aws/regen_iam_passed_roles.py'
- 'tools/aws/test_regen_iam_passed_roles.py'
- 'tools/aws/sources/eks-roles.json'
- 'tools/aws/fetch_eks_roles.py'
- 'tools/aws/test_fetch_eks_roles.py'
- 'tools/aws/sources/emr-roles.json'
- 'tools/aws/fetch_emr_roles.py'
- 'tools/aws/test_fetch_emr_roles.py'
- 'tools/aws/sources/apigateway-roles.json'
- 'tools/aws/fetch_apigateway_roles.py'
- 'tools/aws/test_fetch_apigateway_roles.py'
- 'tools/aws/sources/batch-roles.json'
- 'tools/aws/fetch_batch_roles.py'
- 'tools/aws/test_fetch_batch_roles.py'
- 'tools/aws/sources/backup-roles.json'
- 'tools/aws/fetch_backup_roles.py'
- 'tools/aws/test_fetch_backup_roles.py'
- 'tools/aws/sources/bedrock-agentcore-roles.json'
- 'tools/aws/fetch_bedrock_agentcore_roles.py'
- 'tools/aws/test_fetch_bedrock_agentcore_roles.py'
- 'tools/aws/sources/observabilityadmin-roles.json'
- 'tools/aws/fetch_observabilityadmin_roles.py'
- 'tools/aws/test_fetch_observabilityadmin_roles.py'
- 'src/main/resources/aws/iam-passed-network-connectors.json'
- 'tools/aws/regen_iam_passed_network_connectors.py'
- 'tools/aws/test_regen_iam_passed_network_connectors.py'
- 'src/main/resources/aws/iam-tag-on-create.json'
- 'tools/aws/regen_iam_tag_on_create.py'
- 'tools/aws/test_regen_iam_tag_on_create.py'
- 'tools/aws/sources/rds-tag-actions.json'
- 'tools/aws/fetch_rds_tag_actions.py'
- 'tools/aws/test_fetch_rds_tag_actions.py'
- 'tools/aws/sources/s3tables-tag-keys.json'
- 'tools/aws/fetch_s3tables_tag_keys.py'
- 'tools/aws/test_fetch_s3tables_tag_keys.py'
- 'src/main/resources/aws/iam-request-resources.json'
- 'tools/aws/regen_iam_request_resources.py'
- 'tools/aws/test_regen_iam_request_resources.py'
- 'tools/aws/sources/ec2-id-examples.json'
- 'tools/aws/fetch_ec2_id_examples.py'
- 'tools/aws/test_fetch_ec2_id_examples.py'
- 'tools/aws/sources/ec2-request-samples.json'
- 'tools/aws/fetch_ec2_request_samples.py'
- 'tools/aws/test_fetch_ec2_request_samples.py'
- 'tools/aws/fetch_ssm_session_permissions.py'
- 'tools/aws/sources/ssm-session-permissions.json'
- 'tools/aws/test_fetch_ssm_session_permissions.py'
- 'tools/aws/fetch_sqs_redrive_permissions.py'
- 'tools/aws/sources/sqs-redrive-permissions.json'
- 'tools/aws/test_fetch_sqs_redrive_permissions.py'
- 'tools/aws/sources/apigateway-arn-formats.json'
- 'tools/aws/fetch_apigateway_arn_formats.py'
- 'tools/aws/test_fetch_apigateway_arn_formats.py'
- 'tools/aws/sources/apigateway-tag-inheritance.json'
- 'tools/aws/fetch_apigateway_tag_inheritance.py'
- 'tools/aws/test_fetch_apigateway_tag_inheritance.py'
- 'tools/aws/sources/athena-glue-ddl-permissions.json'
- 'tools/aws/fetch_athena_glue_ddl_permissions.py'
- 'tools/aws/test_fetch_athena_glue_ddl_permissions.py'
- 'tools/aws/sources/backup-arn-formats.json'
- 'tools/aws/fetch_backup_arn_formats.py'
- 'tools/aws/test_fetch_backup_arn_formats.py'
- 'tools/aws/sources/codeartifact-permissions.json'
- 'tools/aws/fetch_codeartifact_permissions.py'
- 'tools/aws/test_fetch_codeartifact_permissions.py'
- 'tools/aws/sources/dms-arn-formats.json'
- 'tools/aws/fetch_dms_arn_formats.py'
- 'tools/aws/test_fetch_dms_arn_formats.py'
- 'tools/aws/sources/dms-tag-keys.json'
- 'tools/aws/fetch_dms_tag_keys.py'
- 'tools/aws/test_fetch_dms_tag_keys.py'
- 'tools/aws/sources/dynamodb-permissions.json'
- 'tools/aws/fetch_dynamodb_permissions.py'
- 'tools/aws/test_fetch_dynamodb_permissions.py'
- 'tools/aws/sources/iam-identifiers.json'
- 'tools/aws/fetch_iam_identifiers.py'
- 'tools/aws/test_fetch_iam_identifiers.py'
- 'tools/aws/sources/kms-api-permissions.json'
- 'tools/aws/fetch_kms_api_permissions.py'
- 'tools/aws/test_fetch_kms_api_permissions.py'
- 'tools/aws/sources/required-resource-types.json'
- 'tools/aws/fetch_required_resource_types.py'
- 'tools/aws/test_fetch_required_resource_types.py'
- 'tools/aws/sources/s3-tag-inheritance.json'
- 'tools/aws/fetch_s3_tag_inheritance.py'
- 'tools/aws/test_fetch_s3_tag_inheritance.py'
- 'src/main/resources/aws/dynamodb-condition-keys.json'
- 'tools/aws/regen_dynamodb_condition_keys.py'
- 'tools/aws/test_regen_dynamodb_condition_keys.py'
- 'src/main/resources/aws/iam-condition-keys.json'
- 'tools/aws/regen_iam_condition_keys.py'
- 'tools/aws/test_regen_iam_condition_keys.py'
- 'tools/aws/fetch_iam_account_property_namespaces.py'
- 'tools/aws/sources/iam-account-property-namespaces.json'
- 'tools/aws/test_fetch_iam_account_property_namespaces.py'
- 'src/main/resources/aws/s3control-tag-condition-keys.json'
- 'tools/aws/regen_s3control_tag_condition_keys.py'
- 'tools/aws/test_regen_s3control_tag_condition_keys.py'
- 'src/main/resources/aws/request-condition-keys.json'
- 'tools/aws/regen_request_condition_keys.py'
- 'tools/aws/test_regen_request_condition_keys.py'
- 'tools/aws/sources/eventbridge-condition-keys.json'
- 'tools/aws/fetch_eventbridge_conditions.py'
- 'tools/aws/test_fetch_eventbridge_conditions.py'
- 'tools/aws/sources/eks-condition-keys.json'
- 'tools/aws/fetch_eks_conditions.py'
- 'tools/aws/test_fetch_eks_conditions.py'
- 'tools/aws/sources/route53-condition-keys.json'
- 'tools/aws/fetch_route53_conditions.py'
- 'tools/aws/test_fetch_route53_conditions.py'
- 'tools/aws/sources/sts-source-identity.json'
- 'tools/aws/fetch_sts_source_identity.py'
- 'tools/aws/test_fetch_sts_source_identity.py'
- 'tools/aws/sources/sts-session-tags.json'
- 'tools/aws/fetch_sts_session_tags.py'
- 'tools/aws/test_fetch_sts_session_tags.py'
- 'tools/aws/sources/sts-oidc-claim-keys.json'
- 'tools/aws/fetch_sts_oidc_claim_keys.py'
- 'tools/aws/test_fetch_sts_oidc_claim_keys.py'
- 'tools/aws/fetch_secretsmanager_required_permissions.py'
- 'tools/aws/sources/secretsmanager-required-permissions.json'
- 'tools/aws/test_fetch_secretsmanager_required_permissions.py'
- 'tools/aws/fetch_lambda_response_permissions.py'
- 'tools/aws/sources/lambda-response-permissions.json'
- 'tools/aws/test_fetch_lambda_response_permissions.py'
- 'tools/aws/fetch_cloudwatch_promql_permissions.py'
- 'tools/aws/sources/cloudwatch-promql-permissions.json'
- 'tools/aws/test_fetch_cloudwatch_promql_permissions.py'
- 'tools/aws/fetch_lambda_layer_permissions.py'
- 'tools/aws/sources/lambda-layer-permissions.json'
- 'tools/aws/test_fetch_lambda_layer_permissions.py'
- 'tools/aws/fetch_rds_cluster_group_permissions.py'
- 'tools/aws/sources/rds-cluster-group-permissions.json'
- 'tools/aws/test_fetch_rds_cluster_group_permissions.py'
- 'src/main/resources/aws/rest-routes.json'
- 'tools/aws/regen_rest_routes.py'
- 'tools/aws/test_regen_rest_routes.py'
- 'src/main/resources/aws/cloudtrail-s3-data-events.json'
- 'tools/aws/sources/cloudtrail-s3-data-events.json'
- 'tools/aws/fetch_cloudtrail_s3_data_events.py'
- 'tools/aws/test_fetch_cloudtrail_s3_data_events.py'
- 'tools/aws/regen_cloudtrail_s3_data_events.py'
- 'tools/aws/test_regen_cloudtrail_s3_data_events.py'
- 'src/main/resources/aws/cloudwatch-otel-enrichment.json'
- 'tools/aws/regen_cloudwatch_otel_enrichment.py'
- 'tools/aws/test_regen_cloudwatch_otel_enrichment.py'
- 'src/main/resources/aws/elasticache-otel-metrics.json'
- 'tools/aws/regen_elasticache_otel_metrics.py'
- 'tools/aws/test_regen_elasticache_otel_metrics.py'
- 'tools/aws/regen_partitions.py'
- 'tools/aws/regen_query_services.py'
- '.github/workflows/iam-data-drift.yml'
- 'tools/aws/test_iam_data_verify.py'
schedule:
# Mondays at 06:00 UTC, before the working week rather than during it.
- cron: '0 6 * * 1'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# One job, and one step that runs both verifies. They are kept in a single Makefile target rather
# than two steps because sequential steps stop at the first failure: while the namespace list was
# stale, the action resource check never ran at all, so the half that was still fine went
# unreported. The target runs both regardless and fails afterwards, naming which file drifted.
jobs:
iam-data-drift:
name: Vendored IAM data still matches upstream
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# A pull request's merge commit and its first parent, the base branch, so the step below
# can tell which files the pull request changes.
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.x"
- name: Test IAM verification selection
run: python3 -m unittest discover -s tools/aws -p test_iam_data_verify.py
# IAM role-tag coverage also depends on which operations name a role in pinned botocore.
- name: Install the pinned botocore
run: pip install -r tools/aws/requirements.txt
# A pull request checks the files it changes; the weekly and manual runs check every file. A
# diff that cannot be read leaves CHANGED empty, which checks every file too.
- name: Check the vendored IAM files still match upstream
env:
EVENT_NAME: ${{ github.event_name }}
run: |
if [ "$EVENT_NAME" = pull_request ]; then
changed_file="$RUNNER_TEMP/iam-changed-paths.txt"
if ! git diff --name-only HEAD^1 HEAD > "$changed_file"; then
: > "$changed_file"
fi
make iam-data-verify CHANGED_FILE="$changed_file"
else
make iam-data-verify
fi