private Optional<ValidationEvent> validateResourcePrimaryIdentifier(
            Model model,
            ResourceShape resource,
            String primaryIdentifier
    ) {
        Map<String, ShapeId> properties = resource.getProperties();
        if (!properties.containsKey(primaryIdentifier)) {
            return Optional.of(error(resource,
                    resource.expectTrait(CfnResourceTrait.class),
                    format("The alternative resource primary identifier, `%s`, must be a property of the resource.",
                            primaryIdentifier)));
        }

        Shape propertyTarget = model.expectShape(properties.get(primaryIdentifier));
        if (!propertyTarget.isStringShape() && !propertyTarget.isEnumShape()) {
            return Optional.of(error(resource,
                    resource.expectTrait(CfnResourceTrait.class),
                    format("The alternative resource primary identifier, `%s`, targets a `%s` shape, it must target a `string`.",
                            primaryIdentifier,
                            propertyTarget.getType())));
        }

        return Optional.empty();
    }
Validates that derived CloudFormation properties all have the same target.
smithy-aws-cloudformation-traits/src/main/java/software/amazon/smithy/aws/cloudformation/traits/CfnResourcePropertyValidator.java