Read ALB ARNs from service module

I have first created ALB in AWS with terraform module and am trying to map already created ALB ARNs under EC2 from other module but I have some difficulties in how to read ALB ARNs from another module which was already created and assign them to EC2?

someone would help me with how to fulfill my requirements?

Also, Please share what is the best way to handle DNS record in Route 53 when destroy and create the resources.

to read existing resources you would need the data block instead of the resource block.
try forming the data block such that the “lookup” will result in fetching the required ALB.
then you can use the data.X.Y.arn syntax to use the arn in something else.

Hi Shantanugadgi,

Thanks for your reply. Would you be able to give the complete example for it? I will be trying that out and posting the results soon

is someone there to help me how to read the ALB ARN or Listener in EC2 module which was already created from ALB module before?