Optional remote state

We have a scenario where we have a microservice (A) that needs to pull additional information about another microservice (B). basically AWS security groups so it can allow the other microservice to hit it. This sounds like a good scenario for remote state except for one thing: In a case where the A is being developed in isolation, we don’t want to require B to be deployed. We can say, based on a flag, use ternary syntax to pull information from the remote state, but by that point, the remote state has already been refreshed, and I believe would fail if it doesn’t exist (i.e. the refresh isn’t done on an as needed basis).

What are my options?

Just have an optional variable you can pass in for the security group details for your module.

Then wherever you use the module you can either not specify (no B deployed) or add the remote state code to pull in the details and pass it through.