Pass variable back to Terraform from Cloud init

Good day,

I am a terraform noobie and would appreciate any help/guidance.

I have a cloud init script that does some provisioning on ec2. I need to capture a value during the provision runtime on ec2 instance 1 and would like to pass this as a variable to ec2 instance2.

Is it possible to pass a variable back into Terraform using either cloudinit_config or a null resource with a remote-exec? Any other resources that can help?