> Can we use uid/gid to set permissions instead of username and groupname?

Yes, you sure can.

 1 2 3 4 5 6 7 8 91011121314151617181920212223
  bundle agent main
  {
    files:

       # Here we use username and groupname
        "/tmp/example"
          create => "true",
          perms => mog( "600", "root", "root" );

       # Here we use uid and gid
        "/tmp/example"
          perms => mog( "600", 1000, 136 );
  }
  body perms mog(mode,user,group)
  # @brief Set the file's mode, owner and group
  # @param mode The new mode
  # @param user The username of the new owner
  # @param group The group name
  {
        owners => { "$(user)" };
        groups => { "$(group)" };
        mode   => "$(mode)";
  }

Run the above example:

12
  chmod 600 /tmp/perms-example.cf
  sudo cf-agent -KIf /tmp/perms-example.cf

Check the results:

    info: Created file '/tmp/example', mode 0600
    info: Owner of '/tmp/example' was 0, setting to 1000
    info: Group of '/tmp/example' was 0, setting to 136