I understand. However, there is an important distinction. Although you may have entities that you logically refer to as terrain entities, the word terrain has a specific meaning in the context of Lumberyard. If refers to a type of level component, and there should only ever be one in the level.
You can test for the Legacy Terrain level component any number of ways in your RayCastHit result. A simple fast way is in the Script Canvas mentioned above, keep the terrain EntityID as a variable in the script and test for equality. You could also use the EntityID in the hit result to try to determine the type if you prefer to make the script canvas a bit more hands off.
EDIT: Maybe I didn’t understand. I see you wrote “Objects on the ground that can NOT be destroyed”. These are entities you call terrain objects because they sit on the ground (terrain component) and can be traversed, correct? You can differentiate these objects by giving a unique tag for objects or a property that defines whether they are destructible, and calling their destruction function when they are hit by a ray. Or you could try doing something clever with the EBus, where you send out a destruction event, but I’m not sure how performant this scenario might be if you have a lot of destructible entities.