As Howard mentioned the elastic_launch function is not part of our public API (yet); therefore, we do not have docs for it, but reading and understanding how the script works and what environment variables it sets, should be helpful since it is a thin wrapper on top of elastic_launch.
Your sage_main_routine should be actually “reversed” like this:
sage_main_routine(foo):
    # These environment variables are set by `elastic_launch`.
    master_addr = os.environ["MASTER_ADDR"]
    master_port = os.environ["MASTER_PORT"]
    world_size = os.environ["WORLD_SIZE"]
    rank = os.environ["RANK"]

    store = TCPStore(master_addr, master_port, world_size, is_master=rank== 0)

    # Rest of the script...

In the main script: 
        config = LaunchConfig(
            min_nodes=1,
            max_nodes=2,
            nproc_per_node=1,
            rdzv_endpoint="10.231.131.7",
            rdzv_backend="c10d",
        )

        foo = "my dummy value"

        outputs = elastic_launch(config, sage.sage_main_routine)(
           foo, # Your custom script arguments
        )