From 0260a54ee2925b0dc088c4dc2156947cddab09bd Mon Sep 17 00:00:00 2001 From: Hector Ventura Date: Mon, 2 Nov 2026 06:56:39 -0600 Subject: [PATCH] chore: keep aws-cdk flags out of botocore-bump and tidy two follow-ups (#7271) regen_partitions.py reads each region's optIn and s3WebsiteDashForm from the aws-cdk checkout, so make botocore-bump could carry unrelated flag changes and aws-data-check-botocore accepted them. Add --carry-region-flags, which keeps the stored flags and refuses a region with none, and use it in the botocore-only targets. aws-data-sync and aws-data-check still read aws-cdk. Hold the ses-account lock in SesCustomVerificationEmailTemplateTest, which sends and could overlap a test that turns account sending off. Correct the lambdaTaggedArn Javadoc, which still described the MicroVM tag target from before #7145. Signed-off-by: Hector Ventura Co-authored-by: Priamo Germosen <6233424+pgermosen@users.noreply.github.com> --- CONTRIBUTING.md | 3 +- Makefile | 14 ++++++-- ...esCustomVerificationEmailTemplateTest.java | 2 ++ .../services/iam/ResourceArnBuilder.java | 4 +-- tools/aws/regen_partitions.py | 23 +++++++----- tools/aws/test_regen_partitions.py | 36 ++++++++++++++++++- 6 files changed, 67 insertions(+), 15 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c61208b70f..64aa7c331b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -356,7 +356,8 @@ regions, opt-in flags, global endpoints) is generated from botocore's published a newer botocore with `make botocore-bump VERSION=`: it sets the pin in `tools/aws/requirements.txt`, moves `local/aws/botocore` to that release's tag, then regenerates and checks only the botocore-derived data, so the bump and its regenerated files land in one pull -request with nothing from the other `local/aws` sources. Dependabot does not track +request with nothing from the other `local/aws` sources: the region flags `partitions.json` takes +from `local/aws/aws-cdk` stay as they are until a `make aws-data-sync`. Dependabot does not track botocore for that reason: its bump alone fails `make aws-data-check`. `make aws-data-sync` also regenerates the IAM managed-policy catalog (`src/main/resources/iam/managed-polic*`) from the `local/aws/iam-dataset` checkout; without that checkout, as in CI, `make aws-data-check` only diff --git a/Makefile b/Makefile index 8de8d26b6f..edda17b514 100644 --- a/Makefile +++ b/Makefile @@ -249,13 +249,15 @@ botocore-bump: ## Bump the botocore pin to VERSION, move local/aws/botocore to t $(MAKE) --no-print-directory aws-data-sync-botocore $(MAKE) --no-print-directory aws-data-check-botocore -aws-data-sync: aws-data-sync-botocore ## Regenerate src/main/resources/aws/*.json and the IAM managed-policy catalog from local/aws (commit the result) +aws-data-sync: ## Regenerate src/main/resources/aws/*.json and the IAM managed-policy catalog from local/aws (commit the result) + $(PYTHON) tools/aws/regen_partitions.py + $(MAKE) --no-print-directory aws-data-sync-botocore $(PYTHON) tools/aws/regen_region_facts.py $(PYTHON) tools/aws/regen_rds_ca_certificates.py $(PYTHON) tools/aws/regen_managed_policies.py aws-data-sync-botocore: ## Regenerate only the AWS data derived from botocore, so a bump picks up nothing from the other local/aws sources - $(PYTHON) tools/aws/regen_partitions.py + $(PYTHON) tools/aws/regen_partitions.py --carry-region-flags $(PYTHON) tools/aws/regen_dynamodb_shapes.py $(PYTHON) tools/aws/regen_redshift_serverless_shapes.py $(PYTHON) tools/aws/regen_resource_groups_shapes.py @@ -273,6 +275,12 @@ aws-data-sync-botocore: ## Regenerate only the AWS data derived from botocore, s $(PYTHON) tools/aws/regen_iam_paginators.py aws-data-check: aws-data-check-botocore ## CI gate: the vendored AWS data must match a fresh generation + @$(PYTHON) tools/aws/regen_partitions.py --check || { \ + echo ""; \ + echo "error: src/main/resources/aws/partitions.json is out of date."; \ + echo " Run 'make aws-data-sync' and commit the result."; \ + exit 1; \ + } @$(PYTHON) tools/aws/regen_region_facts.py --check || { \ echo ""; \ echo "error: src/main/resources/aws/region-facts.json is out of date or malformed."; \ @@ -299,7 +307,7 @@ aws-data-check: aws-data-check-botocore ## CI gate: the vendored AWS data must m } aws-data-check-botocore: ## The AWS data derived from botocore must match a fresh generation - @$(PYTHON) tools/aws/regen_partitions.py --check || { \ + @$(PYTHON) tools/aws/regen_partitions.py --check --carry-region-flags || { \ echo ""; \ echo "error: src/main/resources/aws/partitions.json is out of date."; \ echo " Run 'make aws-data-sync' and commit the result."; \ diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesCustomVerificationEmailTemplateTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesCustomVerificationEmailTemplateTest.java index 3f1d503c87..0f31f29330 100644 --- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesCustomVerificationEmailTemplateTest.java +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesCustomVerificationEmailTemplateTest.java @@ -7,6 +7,7 @@ import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; +import org.junit.jupiter.api.parallel.ResourceLock; import software.amazon.awssdk.services.ses.SesClient; import software.amazon.awssdk.services.ses.model.CreateCustomVerificationEmailTemplateRequest; import software.amazon.awssdk.services.sesv2.SesV2Client; @@ -26,6 +27,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; */ @DisplayName("SES custom verification email templates (v1 + v2)") @TestMethodOrder(MethodOrderer.OrderAnnotation.class) +@ResourceLock("ses-account") class SesCustomVerificationEmailTemplateTest { private static final String FROM = "cvet-sdk-sender@floci-cvet.test"; diff --git a/src/main/java/io/github/hectorvent/floci/services/iam/ResourceArnBuilder.java b/src/main/java/io/github/hectorvent/floci/services/iam/ResourceArnBuilder.java index 401fa451c6..664ece827c 100644 --- a/src/main/java/io/github/hectorvent/floci/services/iam/ResourceArnBuilder.java +++ b/src/main/java/io/github/hectorvent/floci/services/iam/ResourceArnBuilder.java @@ -1134,8 +1134,8 @@ public class ResourceArnBuilder { * The resource a Lambda tag route acts on, from the ARN it names. Tagging looks a function up by the * ARN's Region and name, and a MicroVM image or network connector by the ARN's Region and trailing * name, in the caller's own account whatever account the ARN names, so that resource is the one - * checked. The MicroVM tag handler takes any target holding {@code :microvm-image:} or - * {@code :network-connector:}, an {@code arn:} prefix or not, so the target is read as it reads it. + * checked. The MicroVM tag handler takes only a Lambda ARN naming an image or a connector with no + * version, so the target is read through {@link LambdaMicrovmsService#taggedResource}, as it reads it. * Any other ARN, an event source mapping's included, has to name its resource exactly or is * refused, so it is checked as written. */ diff --git a/tools/aws/regen_partitions.py b/tools/aws/regen_partitions.py index 5c1c7d97a0..93bd3cf653 100644 --- a/tools/aws/regen_partitions.py +++ b/tools/aws/regen_partitions.py @@ -38,8 +38,9 @@ from two sources and a rule: legacy `s3-website-` endpoint form, and commercial regions after `RULE_CLASSIC_PARTITION_BECOMES_OPT_IN` are opt-in (DescribeRegions omits them by default). botocore publishes neither fact. Read from `--cdk` or `local/aws/aws-cdk`; when the checkout - is absent (CI), the two flags are carried over from the existing output file, and a region - with nothing to carry is an error rather than a guess. + is absent (CI), or with `--carry-region-flags` (`make botocore-bump`, so a bump takes nothing + from aws-cdk), the two flags are carried over from the existing output file, and a region with + nothing to carry is an error rather than a guess. Run from anywhere in the repo: python3 tools/aws/regen_partitions.py # rewrite the vendored file in place @@ -342,8 +343,9 @@ def build(partitions_doc: dict, endpoints_doc: dict, entities: list[str] | None, elif region_id in carried_flags: opt_in, dash = carried_flags[region_id] else: - raise ValueError(f"{region_id}: no aws-cdk checkout to derive optIn/s3WebsiteDashForm from and " - f"nothing to carry over from {OUTPUT.name}; run with local/aws/aws-cdk present") + raise ValueError(f"{region_id}: optIn/s3WebsiteDashForm come from the aws-cdk checkout and there is " + f"nothing to carry over from {OUTPUT.name}; run tools/aws/regen_partitions.py " + f"with local/aws/aws-cdk present") regions.append({ "id": region_id, "description": descriptions[region_id], @@ -422,9 +424,12 @@ def generate(botocore_data: Path, provenance: str, cdk_root: Path | None, existi if cdk_root is not None and (cdk_root / CDK_ENTITIES).exists(): entities = parse_cdk_entities((cdk_root / CDK_ENTITIES).read_text(encoding="utf-8")) carried = load_json(existing) if existing.exists() else None - return build(partitions_doc, endpoints_doc, entities, carried, provenance, collect_signing_names(botocore_data), - collect_ruleset_partitions(botocore_data), collect_self_signed_prefixes(botocore_data), - collect_signin_hosts(botocore_data)) + document = build(partitions_doc, endpoints_doc, entities, carried, provenance, collect_signing_names(botocore_data), + collect_ruleset_partitions(botocore_data), collect_self_signed_prefixes(botocore_data), + collect_signin_hosts(botocore_data)) + if cdk_root is None and carried is not None and "regionFlags" in carried.get("_source", {}): + document["_source"]["regionFlags"] = carried["_source"]["regionFlags"] + return document def main(argv: list[str] | None = None) -> int: @@ -432,11 +437,13 @@ def main(argv: list[str] | None = None) -> int: parser.add_argument("--check", action="store_true", help="exit 1 when the vendored file differs from a fresh generation") parser.add_argument("--botocore-data", type=Path, help="botocore data directory (partitions.json, endpoints.json)") parser.add_argument("--cdk", type=Path, default=LOCAL_CDK, help="aws-cdk checkout root (default: local/aws/aws-cdk)") + parser.add_argument("--carry-region-flags", action="store_true", + help="keep the existing optIn and s3WebsiteDashForm flags instead of reading the aws-cdk checkout") parser.add_argument("--output", type=Path, default=OUTPUT, help=argparse.SUPPRESS) args = parser.parse_args(argv) botocore_data, provenance = resolve_botocore_data(args.botocore_data) - document = generate(botocore_data, provenance, args.cdk, args.output) + document = generate(botocore_data, provenance, None if args.carry_region_flags else args.cdk, args.output) rendered = render(document) rel = args.output.relative_to(REPO_ROOT) if args.output.is_relative_to(REPO_ROOT) else args.output diff --git a/tools/aws/test_regen_partitions.py b/tools/aws/test_regen_partitions.py index 9b69a6a62a..5163b3758c 100644 --- a/tools/aws/test_regen_partitions.py +++ b/tools/aws/test_regen_partitions.py @@ -224,7 +224,7 @@ def test_build_without_cdk_carries_flags_from_the_previous_file(): def test_build_without_cdk_refuses_a_region_it_cannot_carry(): - with pytest.raises(ValueError, match="no aws-cdk checkout"): + with pytest.raises(ValueError, match="nothing to carry over"): r.build(PARTITIONS, ENDPOINTS, None, {"partitions": []}, "test") @@ -444,6 +444,40 @@ def test_cli_writes_then_reports_up_to_date_then_detects_drift(tmp_path, capsys) assert "make aws-data-sync" in capsys.readouterr().out +def test_cli_carry_region_flags_ignores_a_cdk_checkout_that_moved(tmp_path, capsys): + data, cdk = write_sources(tmp_path) + output = tmp_path / "partitions.json" + common = ["--botocore-data", str(data), "--cdk", str(cdk), "--output", str(output)] + assert r.main(common) == 0 + written = output.read_text() + + entities = cdk / r.CDK_ENTITIES + moved = ENTITIES.replace(" RULE_CLASSIC_PARTITION_BECOMES_OPT_IN,\n", "") + moved = moved.replace("];", " RULE_CLASSIC_PARTITION_BECOMES_OPT_IN,\n];") + assert moved != ENTITIES + entities.write_text(moved) + assert r.main(["--check"] + common) == 1 + capsys.readouterr() + + assert r.main(["--check", "--carry-region-flags"] + common) == 0 + assert r.main(["--carry-region-flags"] + common) == 0 + assert output.read_text() == written + + +def test_cli_carry_region_flags_refuses_a_new_region(tmp_path): + data, cdk = write_sources(tmp_path) + output = tmp_path / "partitions.json" + common = ["--botocore-data", str(data), "--cdk", str(cdk), "--output", str(output)] + assert r.main(common) == 0 + + partitions = json.loads(json.dumps(PARTITIONS)) + partitions["partitions"][0]["regions"]["eu-new-1"] = {"description": "New"} + (data / "partitions.json").write_text(json.dumps(partitions)) + with pytest.raises(ValueError, match="eu-new-1.*nothing to carry over"): + r.main(["--carry-region-flags"] + common) + assert r.main(common) == 0 + + def test_cli_check_ignores_provenance_differences(tmp_path): data, cdk = write_sources(tmp_path) output = tmp_path / "partitions.json"