programmatically place a plane of water on a procedurally generated terrain

I have implemented the diamond square algorithm to generated a simple terrain. Next, I’d like a plane of water which ends at the bounds of the terrain is is centred with the terrain.

Essentially, I want my plane of water to stretch to each edge of my terrain (the terrain forms a square). Here’s a screenshot of my terrain:

I know unity has a water prefab but I want a water plane that can have its position and bounds programmatically set once the terrain has been generated.

How can I do this?

Here’s how you could copy the mesh vertices and set a water level.

Mesh mesh = terrain.GetComponent<MeshFilter>().mesh;
Vector3[] waterVertices = new Vector3[mesh.Length];

float waterLevel = 0;
for (int i = 0; i < vertices; i++)
{
    waterVertices[i] = mesh.vertices[i];
    waterVertices[i].y = waterLevel;
}