How does syncing variables work in the IoT cloud?

Hey, I have 2 arduino nano 33 IoT board and I connected them to the arduino cloud. I want to board #1 to take a button input and then use that to change a variable in the cloud. Then i want board #2 to the recognize that the first boards variable was changed so it can run code in response. Or have the variables synced so when one things variable changes it changes the other variable too. I saw that you can sync variables but I do not know how it works.