Skip to content

Conversation

@bendrucker
Copy link
Member

@bendrucker bendrucker commented Jun 25, 2025

Replace the AWS SDK Ruby models with the official AWS Smithy API models repository. This enables access to the latest API definitions and removes the dependency on the Ruby SDK, which was included solely for the API models rather than the SDK itself.

Changes

  • Submodule migration: Replace aws-sdk-ruby with aws/api-models-aws repository

    • Update all 127 mapping files to use new Smithy model paths
    • Example: aws-sdk-ruby/apis/apigateway/.../api-2.jsonapi-models-aws/models/api-gateway/.../api-gateway-....json
  • Generator enhancements: Add Smithy format support with type safety

    • Implement type-safe Smithy shape converter using dedicated structs
    • Add service namespace resolver for qualified shape lookups (namespace#ShapeName)
    • Handle both enum-as-trait and enum-as-type Smithy formats
    • Apply pattern transformations for backward compatibility:
      • IAM role ARN patterns: Add .* suffix to match role paths in Terraform configs
      • Cognito SMS messages: Match text containing {####} placeholder
      • WorkSpaces directories: Remove redundant anchors in alternation patterns
  • Resource cleanup: Remove deprecated resources and attributes

    • Remove all OpsWorks resources (no longer in Terraform AWS provider)
    • Remove deprecated attributes from aws_instance, aws_launch_template, aws_eks_addon, aws_redshift_cluster, aws_ssm_association, aws_flow_log, aws_eip, aws_dms_endpoint
  • Generated output changes:

    • All enum values now alphabetically sorted for deterministic output
    • Add 3 new rules: aws_ecs_account_setting_default_invalid_name, aws_guardduty_member_invalid_email, aws_route53_record_invalid_zone_id
    • Successfully generate 250+ rule files with updated patterns

Breaking Changes

Validation Changes (More Strict)

These rules now enforce stricter validation that may reject previously accepted values:

  • Cognito SMS messages (aws_cognito_user_pool_invalid_sms_authentication_message, aws_cognito_user_pool_invalid_sms_verification_message):

    • Now require {####} placeholder within message text, not as standalone value
    • Example: "Your code is {####}" is valid, but "{####}" alone is not
    • This matches Cognito's actual requirements
  • Name validation patterns: Various EC2/ECS resource name patterns now correctly enforce end-of-string validation

    • Previously allowed trailing characters due to missing $ anchor
    • Affected rules include instance names, configuration names, etc.
  • DeviceFarm ARN patterns: Now enforce complete ARN format with proper termination

These changes reflect the authoritative patterns from AWS's official Smithy models.

References

Closes #893
Closes #900

Switch from AWS SDK Ruby models to official Smithy API models repository.
See: https://github.com/aws/api-models-aws

Related to #893
- Implement Smithy shape converter to handle traits-based format
- Add service namespace resolution for qualified shape lookups
- Implement staged pattern transformation with practical compatibility
- Handle both enum-as-trait and enum-as-type formats
- Sort enum values for deterministic output

Key design decisions:
- Prioritize clean, documented pattern transforms over exhaustive mapping
- Accept some breaking changes for simpler architecture
- Maintain critical ARN and validation pattern compatibility
- Remove deprecated attributes no longer in Terraform AWS provider:
  - aws_instance: cpu_core_count, cpu_threads_per_core
  - aws_launch_template: elastic_inference_accelerator, elastic_gpu_specifications
  - aws_spot_instance_request: block_duration_minutes
  - aws_eks_addon: resolve_conflicts
  - aws_redshift_cluster: snapshot_copy, logging (block types)
  - aws_ssm_association: instance_id
  - aws_flow_log: log_group_name
  - aws_eip: vpc
  - aws_dms_endpoint: s3_settings (block type)

- Remove entire opsworks.hcl mapping (all OpsWorks resources removed from provider)

- Successfully generate all rule files from Smithy API models
- New rules added: aws_ecs_account_setting_default, aws_guardduty_member, aws_route53_record_invalid_zone_id
- All enum values now alphabetically sorted for deterministic output
Pattern transforms are now working correctly:
- Cognito SMS message patterns properly transformed from ^\{####\}$ to ^.*\{####\}.*$
- All pattern compatibility transforms applied correctly
- All tests passing
@bendrucker bendrucker force-pushed the convert-smithy-models-repo branch from bd85770 to 5327171 Compare November 12, 2025 03:10
- Remove unnecessary pattern fallbacks (no longer present in Smithy models)
- Add type-safe Smithy shape parsing with dedicated structs
- Replace map[string]interface{} casting with JSON unmarshaling
- Reduce potential panic points from ~20 type assertions to 0

All tests passing. No functional changes to generated code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Use Smithy models from official repository

2 participants