Skip to content

Conversation

@bendrucker
Copy link
Member

@bendrucker bendrucker commented Nov 21, 2025

The aws_dms_s3_endpoint mapping was accidentally removed during the Smithy migration in #901, causing validation rules for this resource to be deleted. This restores the mapping and adds an HCL function-based transform system to handle enum value differences between Smithy models and the Terraform provider to fix mismatched enum values. This problem predated Smithy and is a persistent difference between how the TF provider and the AWS API models represent this attribute.

Changes

  • Restore aws_dms_s3_endpoint mapping in dms.hcl with validation for 8 attributes
  • Implement HCL expression evaluation system in the generator using EvalContext
  • Add uppercase() and replace() transform functions usable directly in mapping expressions
  • Transform enum values to match Terraform provider expectations:
    • compression_type: "none"/"gzip" → "NONE"/"GZIP"
    • encryption_mode: "sse-kms"/"sse-s3" → "SSE_KMS"/"SSE_S3"
    • Other S3 endpoint enums similarly transformed to uppercase

The transform system leverages HCL's built-in EvalContext with custom list-transform function wrappers around stdlib's UpperFunc and ReplaceFunc. This keeps transform logic declarative in mapping files rather than hardcoded in the generator, making it extensible for future cases where Smithy and Terraform formats differ.

References

Closes #989

@bendrucker bendrucker force-pushed the fix-dms-s3-endpoint-mappings branch from 9b91617 to 7f52256 Compare November 21, 2025 01:48
@bendrucker bendrucker changed the title Restore aws_dms_s3_endpoint validation rules with enum transforms aws_dms_s3_endpoint: fix enum validations Nov 21, 2025
@bendrucker bendrucker changed the title aws_dms_s3_endpoint: fix enum validations dms_s3_endpoint: fix enum validations Nov 21, 2025
@bendrucker bendrucker force-pushed the fix-dms-s3-endpoint-mappings branch from 7f52256 to f544f70 Compare November 21, 2025 02:09
Fixes #989

The `aws_dms_s3_endpoint` mapping was accidentally removed during the
Smithy migration in #901. This restores the mapping and adds support
for transforming enum values to match Terraform provider expectations.

## Changes

### Mapping restoration
- Add `aws_dms_s3_endpoint` mapping to `dms.hcl`
- Generate validation rules for 8 attributes (compression_type,
  encryption_mode, data_format, encoding_type, parquet_version,
  date_partition_sequence, date_partition_delimiter, canned_acl_for_objects)

### Transform system
- Implement HCL function-based transform system in generator
- Use `uppercase()` and `replace()` functions directly in mapping expressions
- Leverage HCL's `EvalContext` with custom list-transform wrappers

### Enum value corrections
- `compression_type`: Smithy "none"/"gzip" → Terraform "NONE"/"GZIP"
- `encryption_mode`: Smithy "sse-kms"/"sse-s3" → Terraform "SSE_KMS"/"SSE_S3"
- Other enums similarly transformed to uppercase

This approach keeps transform logic declarative in the mapping files
rather than hardcoded in the generator, making it maintainable and
extensible for future cases where Smithy and Terraform enum formats differ.
@bendrucker bendrucker force-pushed the fix-dms-s3-endpoint-mappings branch from f544f70 to 869771f Compare November 21, 2025 02:13
@bendrucker bendrucker enabled auto-merge (squash) November 21, 2025 02:15
@bendrucker bendrucker merged commit 12bc504 into master Nov 21, 2025
12 checks passed
@bendrucker bendrucker deleted the fix-dms-s3-endpoint-mappings branch November 21, 2025 02:15
bendrucker added a commit that referenced this pull request Nov 21, 2025
Adds comprehensive test coverage for the HCL transform system introduced in #991:
- Unit tests for stringsToCtyList helper
- Tests for makeListTransformFunction with uppercase and replace
- Error case testing for invalid inputs
- Transform composition tests

Improves error handling and code quality:
- Enhanced error messages showing variable names when multiple variables referenced
- Clean eval context handling using fresh variable maps instead of deletion
- Pre-allocated slices for better performance
- Proper empty list handling in cty conversions
- Comprehensive documentation of transform system

All tests pass and generator continues to work correctly.
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.

aws_dms_s3_endpoint incorrect rules (0.44.0)

2 participants