mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
* refactor(cloudformation): read property types from the vendored resource schemas Follow-up asked on #5958: the types EventsCfnProvisioner checked a rule target's members against were written by hand from describe-type, and LambdaCfnProvisioner named the JSON type of each property it reads. They now come from src/main/resources/aws/cfn-property-types.json, which tools/aws/regen_cfn_property_types.py generates from the resource schemas AWS publishes for us-east-1, in the request shapes' layout so RequestShapeModel reads it: a structure, list, map or scalar per shape, and "json" for what a schema leaves free. The schemas come from AWS's live archive rather than a pinned package. cfn-lint ships copies, but widens some types: a Lambda environment variable's value takes any JSON type there and a string in the published schema, where CloudFormation refuses an object or a list with "Property [AB] expected type: String, found: JSONObject" (measured). The archive keeps no older copy, so the generator follows the IAM data's split: --check is offline and structural and runs on every pull request, --verify compares a fresh generation with the vendored file and runs in cfn-schema-drift.yml, weekly and on changes to the file or its generator. CfnPropertyTypes.Reader walks the vendored shapes instead of type trees, maps included: a map's values are read as its value shape, and a mismatch names the key, as CloudFormation does ("Property [h] expected type: String, found: JSONObject", measured). Every member of a rule target is now read against its schema type, not only the four #5958 typed, and Lambda reads the properties it already typed through the same reader, nested members included (VpcConfig.SubnetIds, EphemeralStorage. Size, ImageConfig.Command, TracingConfig.Mode, Environment.Variables). The messages for the newly checked members were measured on CloudFormation (eu-west-1) and are in the tests. * fix(cloudformation): keep a literal list's blank entries where the template put them Review of #5988: the reader read every list of strings through the engine's resolveStringList, which drops blank entries, so a rule target's HttpParameters.PathParameterValues ["", "b"] became ["b"] and moved "b" into the first wildcard. CloudFormation passes a literal list on as written (measured: SecurityGroups ["", "sg-..."] reaches the target as both). A literal list is now read through the engine's new resolveLiteralList, which keeps blanks and still expands a list-valued intrinsic in place; a list an intrinsic yields keeps the engine's reading. Lambda's literal lists, read through the same reader, keep their blanks too, for Lambda to judge as on AWS. resolveLiteralList delegates to the private resolveListElements rather than opening it: tests that mock the engine and call resolveStringList's real code would otherwise get the mock's empty list from it, as IamUserCfnProvisionerTest did. * refactor(cloudformation): read a launch configuration's MetadataOptions by its schema shape Review of #5988: #5964, merged after this branch opened, read AWS::AutoScaling::LaunchConfiguration's MetadataOptions through the type trees this PR removes. The generator now vendors that resource type too, and AutoScalingGroupCfnProvisioner reads the block by the shape its published schema declares (HttpTokens and HttpEndpoint strings, HttpPutResponseHopLimit an integer, the same types #5964 wrote by hand), so its tests pass unchanged. The hop limit's type is an anchor of the generator's offline check.
51 lines
2.0 KiB
YAML
51 lines
2.0 KiB
YAML
name: CloudFormation Schema Drift
|
|
# Checks the vendored CloudFormation property types against the resource schemas AWS publishes.
|
|
# They come from AWS's live schema archive rather than from a pinned dependency, so, as with the
|
|
# IAM data in iam-data-drift.yml, this check can fail without anything in the repository having
|
|
# changed, and it 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 the vendored file or its generator, where a hand-edited type
|
|
# would enter the repository.
|
|
# - Weekly, because the file also goes stale without anyone touching it: AWS changes resource
|
|
# schemas, and a property Floci types by an old schema would refuse a template AWS accepts.
|
|
#
|
|
# The fix for a real failure is `make cfn-property-types-sync` and committing the result. The
|
|
# offline shape check is hermetic and runs per pull request in partition-literals.yml instead.
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- 'src/main/resources/aws/cfn-property-types.json'
|
|
- 'tools/aws/regen_cfn_property_types.py'
|
|
- 'tools/aws/test_regen_cfn_property_types.py'
|
|
- '.github/workflows/cfn-schema-drift.yml'
|
|
schedule:
|
|
# Mondays at 06:10 UTC, beside the IAM data drift check.
|
|
- cron: '10 6 * * 1'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
cfn-schema-drift:
|
|
name: Vendored CloudFormation property types still match AWS
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
with:
|
|
python-version: "3.x"
|
|
|
|
# No dependency install: the generator is stdlib-only.
|
|
- name: Check the vendored property types still match AWS's schemas
|
|
run: make cfn-property-types-verify
|