Create temporary resource

I want to create a snapshot from server. The way to do it “manually” is to create a server, run some commands on the server, shutdown the server and finally create a snapshot.

In my case, the snapshot is what I want and I don’t want to keep the server used for creation of a snapshot (I can recreate it if I need to create a new snapshot).

What is the proper way of creating a resource and cleaning it after with Terraform?

That isn’t something Terraform is suitable for. I’d suggest taking a look at Packer, another Hashicorp tool.