Which version of the provider are you using? The documentation reference you provided is for data sources rather than resources, so this would be a better reference: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_global_replication_group#engine-1.
resource "aws_elasticache_replication_group" "primary" {
replication_group_id = "example-primary"
description = "primary replication group"
engine = "valkey"
engine_version = "7.0" # or whichever version you need
node_type = "cache.m5.large"
num_cache_clusters = 1
}